]> granicus.if.org Git - python/commitdiff
#16919: test_crypt now works with unittest test discovery. Patch by Zachary Ware.
authorEzio Melotti <ezio.melotti@gmail.com>
Fri, 11 Jan 2013 03:18:45 +0000 (05:18 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Fri, 11 Jan 2013 03:18:45 +0000 (05:18 +0200)
Lib/test/test_crypt.py
Misc/NEWS

index dc107d8970945361cd958e4b235af7370d2f3f8a..cfb7341e20a9b15644b617b23f80f893e1f707a0 100644 (file)
@@ -1,7 +1,11 @@
 from test import support
 import unittest
 
-crypt = support.import_module('crypt')
+def setUpModule():
+    # this import will raise unittest.SkipTest if _crypt doesn't exist,
+    # so it has to be done in setUpModule for test discovery to work
+    global crypt
+    crypt = support.import_module('crypt')
 
 class CryptTestCase(unittest.TestCase):
 
@@ -29,8 +33,5 @@ class CryptTestCase(unittest.TestCase):
         self.assertTrue(len(crypt.methods) >= 1)
         self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1])
 
-def test_main():
-    support.run_unittest(CryptTestCase)
-
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
index 1ed665a803ebad74e0dcadc8059b6a40fd8d5f8a..7360af4436c11635cc32d614df249f142a36ccaa 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -421,6 +421,9 @@ Library
 Tests
 -----
 
+- Issue #16919: test_crypt now works with unittest test discovery.
+  Patch by Zachary Ware.
+
 - Issue #16910: test_bytes, test_unicode, and test_userstring now work with
   unittest test discovery.  Patch by Zachary Ware.