[Python-checkins] cpython: Isolate the test_source() test in test_collections

raymond.hettinger python-checkins at python.org
Thu Mar 24 17:45:54 CET 2011


http://hg.python.org/cpython/rev/4f1cd92fe835
changeset: 68901:4f1cd92fe835
user: Raymond Hettinger <python at rcn.com>
date: Thu Mar 24 09:45:43 2011 -0700
summary:
 Isolate the test_source() test in test_collections
files:
 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
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -330,13 +330,16 @@
 
 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')
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /