summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-01-11 03:18:45 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-01-11 03:18:45 (GMT)
commit90bbbd11648e8d64013369a595b982788fa89819 (patch)
treedc0c14b41731d1ce9e3b1845ef9858f442d99349
parentd394455aaebaebe98732ebe4d66c9a28acc1139e (diff)
downloadcpython-90bbbd11648e8d64013369a595b982788fa89819.zip
cpython-90bbbd11648e8d64013369a595b982788fa89819.tar.gz
cpython-90bbbd11648e8d64013369a595b982788fa89819.tar.bz2
#16919: test_crypt now works with unittest test discovery. Patch by Zachary Ware.
-rw-r--r--Lib/test/test_crypt.py11
-rw-r--r--Misc/NEWS3
2 files changed, 9 insertions, 5 deletions
diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py
index dc107d8..cfb7341 100644
--- a/Lib/test/test_crypt.py
+++ b/Lib/test/test_crypt.py
@@ -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()
diff --git a/Misc/NEWS b/Misc/NEWS
index 1ed665a..7360af4 100644
--- 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.