What steps will reproduce the problem?
<myfunc.py>
def func():
""" doctest with no output
>>> a = 10
"""
</myfunc.py>
nosetests --with-doctest myfunc.py -s --doctest-result-variable=thing
Results in:
======================================================================
ERROR: Doctest: myfunc.func
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/nose-1.0.0-py2.6.egg/nose/plugins/doctests.py", line 397, in tearDown
delattr(__builtin__, self._result_var)
AttributeError: thing
This is latest clone from google code on OSX.
It seems reasonable to check if the variable is defined before removing it:
diff -r 43d9088a4553 nose/plugins/doctests.py
--- a/nose/plugins/doctests.py Fri Aug 05 10:26:21 2011 -0500
+++ b/nose/plugins/doctests.py Sun Aug 14 01:48:55 2011 -0700
@@ -392,7 +392,8 @@
super(DocTestCase, self).tearDown()
if self._result_var is not None:
sys.displayhook = self._old_displayhook
- delattr(builtin_mod, self._result_var)
+ if hasattr(builtin_mod, self._result_var):
+ delattr(builtin_mod, self._result_var)
class DocFileCase(doctest.DocFileCase):
@@ -425,4 +426,5 @@
super(DocFileCase, self).tearDown()
if self._result_var is not None:
sys.displayhook = self._old_displayhook
- delattr(builtin_mod, self._result_var)
+ if hasattr(builtin_mod, self._result_var):
+ delattr(builtin_mod, self._result_var)
Original issue reported on code.google.com by matthew....@gmail.com on 14 Aug 2011 at 8:50
Original issue reported on code.google.com by
matthew....@gmail.com
on 14 Aug 2011 at 8:50