]> granicus.if.org Git - python/commitdiff
A fix for running unittest tests on platforms without the audioop module (e.g. jython...
authorMichael Foord <fuzzyman@voidspace.org.uk>
Sat, 27 Mar 2010 12:55:19 +0000 (12:55 +0000)
committerMichael Foord <fuzzyman@voidspace.org.uk>
Sat, 27 Mar 2010 12:55:19 +0000 (12:55 +0000)
Lib/unittest/test/dummy.py [new file with mode: 0644]
Lib/unittest/test/test_loader.py

diff --git a/Lib/unittest/test/dummy.py b/Lib/unittest/test/dummy.py
new file mode 100644 (file)
index 0000000..e4f14e4
--- /dev/null
@@ -0,0 +1 @@
+# Empty module for testing the loading of modules
index 7a3a59dc0a27c907538dbe66053e8cddafd32102..032423ab46564679ea4f0a4236d201a2fd7b57c2 100644 (file)
@@ -524,12 +524,8 @@ class Test_TestLoader(unittest.TestCase):
         # 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 @@ class Test_TestLoader(unittest.TestCase):
             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 @@ class Test_TestLoader(unittest.TestCase):
         # 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 @@ class Test_TestLoader(unittest.TestCase):
             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: