[issue12928] exec not woking in unittest
Ezio Melotti
report at bugs.python.org
Thu Sep 8 12:12:30 CEST 2011
Ezio Melotti <ezio.melotti at gmail.com> added the comment:
This doesn't seem related to unittest:
>>> class MyTest:
... def test_a(self):
... b = 1
... exec(compile("a = b + 1", '', 'single'))
... assert a == 2
...
>>> t = MyTest()
>>> t.test_a()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in test_a
NameError: global name 'a' is not defined
With unittest I get the same error.
----------
nosy: +ezio.melotti
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12928>
_______________________________________
More information about the Python-bugs-list
mailing list