[Python-checkins] r79464 - in python/trunk/Lib/unittest/test: dummy.py test_loader.py

michael.foord python-checkins at python.org
Sat Mar 27 13:55:19 CET 2010


Author: michael.foord
Date: Sat Mar 27 13:55:19 2010
New Revision: 79464

Log:
A fix for running unittest tests on platforms without the audioop module (e.g. jython and IronPython)

Added:
   python/trunk/Lib/unittest/test/dummy.py   (contents, props changed)
Modified:
   python/trunk/Lib/unittest/test/test_loader.py

Added: python/trunk/Lib/unittest/test/dummy.py
==============================================================================
--- (empty file)
+++ python/trunk/Lib/unittest/test/dummy.py	Sat Mar 27 13:55:19 2010
@@ -0,0 +1 @@
+# Empty module for testing the loading of modules

Modified: python/trunk/Lib/unittest/test/test_loader.py
==============================================================================
--- python/trunk/Lib/unittest/test/test_loader.py	(original)
+++ python/trunk/Lib/unittest/test/test_loader.py	Sat Mar 27 13:55:19 2010
@@ -524,12 +524,8 @@
         # We're going to try to load this module as a side-effect, so it
         # better not be loaded before we try.
         #
-        # Why pick audioop? Google shows it isn't used very often, so there's
-        # a good chance that it won't be imported when this test is run
-        module_name = 'audioop'
-
-        if module_name in sys.modules:
-            del sys.modules[module_name]
+        module_name = 'unittest.test.dummy'
+        sys.modules.pop(module_name, None)
 
         loader = unittest.TestLoader()
         try:
@@ -538,7 +534,7 @@
             self.assertIsInstance(suite, loader.suiteClass)
             self.assertEqual(list(suite), [])
 
-            # audioop should now be loaded, thanks to loadTestsFromName()
+            # module should now be loaded, thanks to loadTestsFromName()
             self.assertIn(module_name, sys.modules)
         finally:
             if module_name in sys.modules:
@@ -911,12 +907,8 @@
         # We're going to try to load this module as a side-effect, so it
         # better not be loaded before we try.
         #
-        # Why pick audioop? Google shows it isn't used very often, so there's
-        # a good chance that it won't be imported when this test is run
-        module_name = 'audioop'
-
-        if module_name in sys.modules:
-            del sys.modules[module_name]
+        module_name = 'unittest.test.dummy'
+        sys.modules.pop(module_name, None)
 
         loader = unittest.TestLoader()
         try:
@@ -925,7 +917,7 @@
             self.assertIsInstance(suite, loader.suiteClass)
             self.assertEqual(list(suite), [unittest.TestSuite()])
 
-            # audioop should now be loaded, thanks to loadTestsFromName()
+            # module should now be loaded, thanks to loadTestsFromName()
             self.assertIn(module_name, sys.modules)
         finally:
             if module_name in sys.modules:


More information about the Python-checkins mailing list