summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-02-08 11:49:02 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-02-08 11:49:02 (GMT)
commit04054d9ac202d3731d01224c44d01617742367ce (patch)
tree61e6a9aef568fe96936e3d5bdcea2a6b65aac920 /Lib/test/test_support.py
parentedb48814414bef3a68942434142f90594d21236b (diff)
downloadcpython-04054d9ac202d3731d01224c44d01617742367ce.zip
cpython-04054d9ac202d3731d01224c44d01617742367ce.tar.gz
cpython-04054d9ac202d3731d01224c44d01617742367ce.tar.bz2
Update test_support for my temp_dir/change_cwd changes
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index e83a4d6..dd0c7bc 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}: '),
+ 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}: '),
+ 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}: '),
+ msg)
# Tests for temp_cwd()