T
thomas.guest
I'm not making progress with the following and would appreciate any
help.
Here's an interpreted Python session.
File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined
Suppose I want to doctest this behaviour. I cut and paste the above
into a file "test.txt" then run:
python -c "import doctest; doctest.testfile('test.txt')"
This gives me unexpected test failures:
python -c "import doctest; doctest.testfile('test.txt')"
**********************************************************************
File "test.txt", line 5, in test.txt
Failed example:
delattr(this_module, 'f')
Exception raised:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/doctest.py", line 1212, in __run
compileflags, 1) in test.globs
File "<doctest test.txt[3]>", line 1, in <module>
delattr(this_module, 'f')
AttributeError: f
**********************************************************************
File "test.txt", line 6, in test.txt
Failed example:
f()
Expected:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined
Got nothing
**********************************************************************
1 items had failures:
2 of 5 in test.txt
***Test Failed*** 2 failures.
help.
Here's an interpreted Python session.
Traceback (most recent call last):import sys
def f(): pass ....
this_module = sys.modules[__name__]
delattr(this_module, 'f')
f()
File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined
Suppose I want to doctest this behaviour. I cut and paste the above
into a file "test.txt" then run:
python -c "import doctest; doctest.testfile('test.txt')"
This gives me unexpected test failures:
python -c "import doctest; doctest.testfile('test.txt')"
**********************************************************************
File "test.txt", line 5, in test.txt
Failed example:
delattr(this_module, 'f')
Exception raised:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/doctest.py", line 1212, in __run
compileflags, 1) in test.globs
File "<doctest test.txt[3]>", line 1, in <module>
delattr(this_module, 'f')
AttributeError: f
**********************************************************************
File "test.txt", line 6, in test.txt
Failed example:
f()
Expected:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined
Got nothing
**********************************************************************
1 items had failures:
2 of 5 in test.txt
***Test Failed*** 2 failures.