diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2017-02-09 16:09:03 +0100 |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2017-02-09 16:09:03 +0100 |
commit | 2a1d833d5da7fa7a01a2eef183b0a208ed019427 (patch) | |
tree | 8da3ebb695ae55c69d0a58691403fb13d96a9476 /Lib/test/test_support.py | |
parent | c6180bb73c8c7c7f9d8ea9816487b710597b6fc1 (diff) | |
parent | bbd3587a29510bd5a318e0a19fc8570c0cd3b622 (diff) | |
download | cpython-2a1d833d5da7fa7a01a2eef183b0a208ed019427.tar.gz |
Merge issue #26355 fix from 3.6
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r-- | Lib/test/test_support.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index e83a4d6426..0dbe02eeb3 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -155,8 +155,11 @@ class TestSupport(unittest.TestCase): finally: shutil.rmtree(path) - expected = ['tests may fail, unable to create temp dir: ' + path] - self.assertEqual(warnings, expected) + self.assertEqual(len(warnings), 1, warnings) + warn = warnings[0] + self.assertTrue(warn.startswith(f'tests may fail, unable to create ' + f'temporary directory {path!r}: '), + warn) # Tests for change_cwd() @@ -197,8 +200,12 @@ class TestSupport(unittest.TestCase): self.assertEqual(os.getcwd(), new_cwd) warnings = [str(w.message) for w in recorder.warnings] - expected = ['tests may fail, unable to change CWD to: ' + bad_dir] - self.assertEqual(warnings, expected) + self.assertEqual(len(warnings), 1, warnings) + warn = warnings[0] + self.assertTrue(warn.startswith(f'tests may fail, unable to change ' + f'the current working directory ' + f'to {bad_dir!r}: '), + warn) # Tests for change_cwd() @@ -209,7 +216,13 @@ class TestSupport(unittest.TestCase): with support.change_cwd(path=path, quiet=True): pass messages = [str(w.message) for w in recorder.warnings] - self.assertEqual(messages, ['tests may fail, unable to change CWD to: ' + path]) + + self.assertEqual(len(messages), 1, messages) + msg = messages[0] + self.assertTrue(msg.startswith(f'tests may fail, unable to change ' + f'the current working directory ' + f'to {path!r}: '), + msg) # Tests for temp_cwd() |