summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-02-08 12:25:00 +0100
committerVictor Stinner <victor.stinner@gmail.com>2017-02-08 12:25:00 +0100
commit670b6caa1c2f904027ade62c4dfb2a978860db63 (patch)
treeee0b512d5abf5c1fe0eedea0737d83f4badbd748
parentb4e41f42fc0d0d07c18a8e2b752699c379ad3c78 (diff)
downloadcpython-670b6caa1c2f904027ade62c4dfb2a978860db63.tar.gz
support: add more info on temp_dir() and change_cwd() failure
Log the OSError exception message.
-rw-r--r--Lib/test/support/__init__.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 345e16d754..58e4f92ead 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -954,10 +954,11 @@ def temp_dir(path=None, quiet=False):
try:
os.mkdir(path)
dir_created = True
- except OSError:
+ except OSError as exc:
if not quiet:
raise
- warnings.warn('tests may fail, unable to create temp dir: ' + path,
+ warnings.warn(f'tests may fail, unable to create '
+ f'temporary directory {path}: {exc}',
RuntimeWarning, stacklevel=3)
try:
yield path
@@ -981,10 +982,11 @@ def change_cwd(path, quiet=False):
saved_dir = os.getcwd()
try:
os.chdir(path)
- except OSError:
+ except OSError as exc:
if not quiet:
raise
- warnings.warn('tests may fail, unable to change CWD to: ' + path,
+ warnings.warn(f'tests may fail, unable to change current working '
+ f'directory to {path}: {exc}',
RuntimeWarning, stacklevel=3)
try:
yield os.getcwd()