diff options
author | Raymond Hettinger <python@rcn.com> | 2011-03-24 16:45:43 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-03-24 16:45:43 (GMT) |
commit | d4652fab512910ef501b6c62aca5f19bf18bfe74 (patch) | |
tree | 0b3a337d04b0d7530a8ab9833fdbbf6aa2c4797b /Lib/test/test_collections.py | |
parent | 73bd0448b9ab5bfab7ba4b80cc384b2ce828da06 (diff) | |
download | cpython-d4652fab512910ef501b6c62aca5f19bf18bfe74.zip cpython-d4652fab512910ef501b6c62aca5f19bf18bfe74.tar.gz cpython-d4652fab512910ef501b6c62aca5f19bf18bfe74.tar.bz2 |
Isolate the test_source() test in test_collections
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r-- | Lib/test/test_collections.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 4ef27ce..020f4e2 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -330,13 +330,16 @@ class TestNamedTuple(unittest.TestCase): def test_source(self): # verify that _source can be run through exec() - tmp = namedtuple('Color', 'red green blue') - self.assertNotIn('Color', globals()) + tmp = namedtuple('NTColor', 'red green blue') + globals().pop('NTColor', None) # remove artifacts from other tests + self.assertNotIn('NTColor', globals()) exec(tmp._source, globals()) - self.assertIn('Color', globals()) - c = Color(10, 20, 30) + self.assertIn('NTColor', globals()) + c = NTColor(10, 20, 30) self.assertEqual((c.red, c.green, c.blue), (10, 20, 30)) - self.assertEqual(Color._fields, ('red', 'green', 'blue')) + self.assertEqual(NTColor._fields, ('red', 'green', 'blue')) + globals().pop('NTColor', None) # clean-up after this test + self.assertNotIn('NTColor', globals()) def test_source_importable(self): tmp = namedtuple('Color', 'hue sat val') |