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
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()