[Python-checkins] bpo-25172: Reduce scope of crypt import tests (GH-17881)

Miss Islington (bot) webhook-mailer at python.org
Thu Jan 9 12:20:07 EST 2020

commit: 8c08518c255747a06d00479f21087f0c934d0ad6
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-01-09T09:19:59-08:00

bpo-25172: Reduce scope of crypt import tests (GH-17881)

(cherry picked from commit ed367815eeb9329c48a86a8a7fa3186e27a10f2c)

Co-authored-by: Steve Dower <steve.dower at python.org>

M Lib/test/test_crypt.py

diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py
index d29e005fdad50..5dc83b4ecbfa0 100644
--- a/Lib/test/test_crypt.py
+++ b/Lib/test/test_crypt.py
@@ -6,20 +6,21 @@
     import crypt
     IMPORT_ERROR = None
 except ImportError as ex:
+    if sys.platform != 'win32':
+        raise unittest.SkipTest(str(ex))
     crypt = None
     IMPORT_ERROR = str(ex)
- at unittest.skipIf(crypt, 'This should only run on windows')
+ at unittest.skipUnless(sys.platform == 'win32', 'This should only run on windows')
+ at unittest.skipIf(crypt, 'import succeeded')
 class TestWhyCryptDidNotImport(unittest.TestCase):
-    def test_failure_only_for_windows(self):
-        self.assertEqual(sys.platform, 'win32')
     def test_import_failure_message(self):
         self.assertIn('not supported', IMPORT_ERROR)
- at unittest.skipUnless(crypt, 'Not supported on Windows')
+ at unittest.skipUnless(crypt, 'crypt module is required')
 class CryptTestCase(unittest.TestCase):
     def test_crypt(self):

More information about the Python-checkins mailing list