From 30583d89cbaff35e7688f54ea00c6d293f9d50d6 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 6 Jan 2020 13:26:26 -0800 Subject: [PATCH 1/2] Reduce scope of crypt import tests --- Lib/test/test_crypt.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py index d29e005fdad5067..c6caf38e4b3a9c8 100644 --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,25 +1,25 @@ import sys import unittest - try: import crypt IMPORT_ERROR = None except ImportError as ex: + if sys.platform != 'win32': + raise unittest.SkipTest(str(ex)) crypt = None IMPORT_ERROR = str(ex) -@unittest.skipIf(crypt, 'This should only run on windows') +@unittest.skipUnless(sys.platform == 'win32', 'This should only run on windows') +@unittest.skipUnless(IMPORT_ERROR, '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) -@unittest.skipUnless(crypt, 'Not supported on Windows') +@unittest.skipUnless(crypt, 'crypt module is required') class CryptTestCase(unittest.TestCase): def test_crypt(self): From caf8750aee82ad70e030864f234f71d4c8c9c74c Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 8 Jan 2020 15:21:00 -0800 Subject: [PATCH 2/2] Simplify skips --- Lib/test/test_crypt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py index c6caf38e4b3a9c8..5dc83b4ecbfa008 100644 --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,6 +1,7 @@ import sys import unittest + try: import crypt IMPORT_ERROR = None @@ -12,7 +13,7 @@ @unittest.skipUnless(sys.platform == 'win32', 'This should only run on windows') -@unittest.skipUnless(IMPORT_ERROR, 'import succeeded') +@unittest.skipIf(crypt, 'import succeeded') class TestWhyCryptDidNotImport(unittest.TestCase): def test_import_failure_message(self):