|
| 1 | +import logging |
1 | 2 | import collections.abc |
2 | 3 | import contextlib |
3 | 4 | import errno |
@@ -378,8 +379,7 @@ def _waitfor(func, pathname, waitall=False): |
378 | 379 | # Increase the timeout and try again |
379 | 380 | time.sleep(timeout) |
380 | 381 | timeout *= 2 |
381 | | - warnings.warn('tests may fail, delete still pending for ' + pathname, |
382 | | - RuntimeWarning, stacklevel=4) |
| 382 | + logging.getLogger(__name__).warning('tests may fail, delete still pending for %s', pathname) |
383 | 383 |
|
384 | 384 | def _unlink(filename): |
385 | 385 | _waitfor(os.unlink, filename) |
@@ -494,9 +494,12 @@ def temp_dir(path=None, quiet=False): |
494 | 494 | except OSError as exc: |
495 | 495 | if not quiet: |
496 | 496 | raise |
497 | | - warnings.warn(f'tests may fail, unable to create ' |
498 | | - f'temporary directory {path!r}: {exc}', |
499 | | - RuntimeWarning, stacklevel=3) |
| 497 | + logger.getLogger(__name__).warning( |
| 498 | + "tests may fail, unable to create temporary directory %r: %s", |
| 499 | + path, |
| 500 | + exc, |
| 501 | + exc_info=exc, |
| 502 | + ) |
500 | 503 | if dir_created: |
501 | 504 | pid = os.getpid() |
502 | 505 | try: |
@@ -527,9 +530,13 @@ def change_cwd(path, quiet=False): |
527 | 530 | except OSError as exc: |
528 | 531 | if not quiet: |
529 | 532 | raise |
530 | | - warnings.warn(f'tests may fail, unable to change the current working ' |
531 | | - f'directory to {path!r}: {exc}', |
532 | | - RuntimeWarning, stacklevel=3) |
| 533 | + logging.getLogger(__name__).warning( |
| 534 | + 'tests may fail, unable to change the current working directory ' |
| 535 | + 'to %r: %s', |
| 536 | + path, |
| 537 | + exc, |
| 538 | + exc_info=exc, |
| 539 | + ) |
533 | 540 | try: |
534 | 541 | yield os.getcwd() |
535 | 542 | finally: |
|
0 commit comments