[issue12928] exec not woking in unittest

2011-09-08 Thread Benjamin Peterson
Benjamin Peterson added the comment: You're invoking undefined behavior by modifying function locals in exec(). -- nosy: +benjamin.peterson resolution: -> invalid status: open -> closed ___ Python tracker ___

[issue12928] exec not woking in unittest

2011-09-08 Thread Ezio Melotti
Ezio Melotti 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 "",

[issue12928] exec not woking in unittest

2011-09-07 Thread simon
simon added the comment: Can't get this one working: import unittest class MyTest(unittest.TestCase): def test_a(self): b = 1 exec(compile("a = b + 1", '', 'single')) assert a == 2 if __name__ == '__main__': unittest.main() -- __

[issue12928] exec not woking in unittest

2011-09-07 Thread simon
simon added the comment: seems i need to use exec(compile("a = 1", '', 'single'), globals()) -- ___ Python tracker ___ ___ Python-bu

[issue12928] exec not woking in unittest

2011-09-07 Thread simon
New submission from simon : works in 2.6, fails in 3.2.2 import unittest class MyTest(unittest.TestCase): def test_a(self): exec(compile("a = 1", '', 'single')) assert a == 1 if __name__ == '__main__': unittest.main() -- components: Library (Lib) messages: 143672