Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet326/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   322   323   324   325   326   327   328   329   ...   453
lISTINg 15-1: 
 A test IronPython class for use in the examples
# The class you want to access externally.
class DoCalculations():
# A method within the class that adds two numbers.
def DoAdd(self, First, Second):
# Provide a result.
return First + Second
# A test suite in IronPython.
def __test__():
# Create the object.
MyCalc = DoCalculations()
# Perform the test.
print MyCalc.DoAdd(5, 10)
# Pause after the test session.
raw_input(‘\nPress any key to continue...’)
# Execute the test. 
# Comment this call out when you finish testing the code.
__test__()
The class used for this example is 
DoCalculations()
. It contains a single method, 
DoAdd()
, that 
returns the sum of two numbers, 
First
and 
Second
. Overall, the class is simple.
The 
TestClass.py
file also contains a 
__test__()
function. This function creates an instance of 
DoCalculations()

MyCalc
. It then prints the result of calling the 
DoAdd()
method with values
of 
5
and 
10
. The example waits until you press Enter to exit.
In 
__main__()
, you see a call to 
__test__()
. You can execute the example at the command line,
as shown in Figure 15-1. Make sure you use the 
–D
command line switch to place the interpreter
in debug mode. You could also open 
IPY.EXE
interactively, load the file, and execute it inside the 
interpreter. When you know that the code works properly, be sure to comment out the call to
__test__()
in 
__main__()
.
548592c15.indd 311
2/25/10 9:45:54 AM
www.finebook.ir


312

CHAPTER 15
Using ironPython from other .net LangUages 
FIgURE 15-1: 
Test the external module before you use it with your application.
Make absolutely certain that you comment out the call to 
__test__()
 after you 
finish testing the code. Otherwise, the IronPython module will be in test mode 
when you use it in your application.

Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   322   323   324   325   326   327   328   329   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish