<< Chapter < Page | Chapter >> Page > |
Figure 33 . Question 9 possible output. |
---|
Trying:
divide(1,3)Expecting:
0.3333333333333333ok
1 items had no tests:__main__.divide
1 items passed all tests:1 tests in __main__
1 tests in 2 items.1 passed and 0 failed.
Test passed. |
Go to answer 9
What is the meaning of the following two images?
These images were inserted here simply to insert some space between the questions and the answers to keep them from being visible on the screen at thesame time.
This image was also inserted for the purpose of inserting space between the questions and the answers.
False. The actual output is shown in Figure 34 . This question was included topoint out that testing floating point results can be problematic. Many floating point values are simply estimates. Although this example was purposely caused tofail, a given floating point computation may not produce exactly the same results on different platforms. Therefore a test that specifies a given floatingpoint result may pass on one platform and fail on a different platform. The Python Standard Library -- 26.2 doctest -- Test interactive Python examples provides some suggestions for dealing with this issue.
Figure 34 . Question 9 actual output. |
---|
Trying:
divide(1,3)Expecting:
0.333333**********************************************************************
File "Py1359_1720r_09.py", line 4, in __main__Failed example:
divide(1,3)Expected:
0.333333Got:
0.33333333333333331 items had no tests:
__main__.divide**********************************************************************
1 items had failures:1 of 1 in __main__
1 tests in 2 items.0 passed and 1 failed.
***Test Failed*** 1 failures. |
Notification Switch
Would you like to follow the 'Itse 1359 introduction to scripting languages: python' conversation and receive update notifications?