def test_cp16519(self): __main__ = __import__(__name__) __main__.Dict = {"1": "a"} self.assertEqual(__main__.Dict["1"], "a") del __main__.Dict import sys sys.Dict = {"1": "b"} self.assertEqual(sys.Dict["1"], "b") del sys.Dict with path_modifier(os.path.join(source_root(), 'Tests')): import testpkg1 testpkg1.Dict = {"1": "c"} self.assertEqual(testpkg1.Dict["1"], "c") del testpkg1.Dict
def test_cp16519(self): __main__ = __import__(__name__) __main__.Dict = {"1": "a"} self.assertEqual(__main__.Dict["1"], "a") del __main__.Dict import sys sys.Dict = {"1": "b"} self.assertEqual(sys.Dict["1"], "b") del sys.Dict with path_modifier(os.path.join(source_root(), 'Tests')): import testpkg1 testpkg1.Dict = {"1": "c"} self.assertEqual(testpkg1.Dict["1"], "c") del testpkg1.Dict
import unittest from iptest import path_modifier, run_test, skipUnlessIronPython, source_root def gen_testcase(exc_name): def test(self): import IronPython.Runtime.Exceptions as IRE e0 = eval("IRE.%s()" % exc_name) e2 = eval("IRE.%s('msg', e0)" % exc_name) self.assertEqual(e0.Message, e2.InnerException.Message) self.assertEqual("msg", e2.Message) return test @skipUnlessIronPython() class ExceptionsGeneratedTest(unittest.TestCase): def setUp(self): super(ExceptionsGeneratedTest, self).setUp() import clr clr.AddReference("IronPython") with path_modifier(os.path.join(source_root(), 'Src', 'Scripts')): from generate_exceptions import pythonExcs as test_cases test_cases = [x.replace('Error', '') + 'Exception' for x in test_cases] for exc_name in test_cases: test_name = 'test_%s' % exc_name test = gen_testcase(exc_name) setattr(ExceptionsGeneratedTest, test_name, test) run_test(__name__)
import sys import unittest from iptest import path_modifier, run_test, skipUnlessIronPython, source_root def gen_testcase(exc_name): def test(self): import IronPython.Runtime.Exceptions as IRE e0 = eval("IRE.%s()" % exc_name) e2 = eval("IRE.%s('msg', e0)" % exc_name) self.assertEqual(e0.Message, e2.InnerException.Message) self.assertEqual("msg", e2.Message) return test @skipUnlessIronPython() class ExceptionsGeneratedTest(unittest.TestCase): def setUp(self): super(ExceptionsGeneratedTest, self).setUp() import clr clr.AddReference("IronPython") with path_modifier(os.path.join(source_root(), 'Src', 'Scripts')): from generate_exceptions import pythonExcs as test_cases test_cases = [x.replace('Error', '') + 'Exception' for x in test_cases] for exc_name in test_cases: test_name = 'test_%s' % exc_name test = gen_testcase(exc_name) setattr(ExceptionsGeneratedTest, test_name, test) run_test(__name__)