[Python-checkins] cpython: Update test_support for my temp_dir/change_cwd changes
victor.stinner
python-checkins at python.org
Wed Feb 8 06:49:13 EST 2017
https://hg.python.org/cpython/rev/b86f698aeee7
changeset: 106468:b86f698aeee7
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Feb 08 12:49:02 2017 +0100
summary:
Update test_support for my temp_dir/change_cwd changes
files:
Lib/test/support/__init__.py | 2 +-
Lib/test/test_support.py | 23 ++++++++++++++++++-----
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -985,7 +985,7 @@
except OSError as exc:
if not quiet:
raise
- warnings.warn(f'tests may fail, unable to change current working '
+ warnings.warn(f'tests may fail, unable to change the current working '
f'directory to {path}: {exc}',
RuntimeWarning, stacklevel=3)
try:
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -155,8 +155,11 @@
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 @@
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 @@
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()
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list