diff options
| author | Barney Gale <barney.gale@gmail.com> | 2022-02-08 21:01:37 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-08 21:01:37 (GMT) |
| commit | 06e1701ad3956352bc0f42b8f51c2f8cc85bf378 (patch) | |
| tree | 3d6177468f6e1cc7ce4fe9df0e7985a0d6bc77b7 /Lib/test/test_pathlib.py | |
| parent | 81c72044a181dbbfbf689d7a977d0d99090f26a8 (diff) | |
| download | cpython-06e1701ad3956352bc0f42b8f51c2f8cc85bf378.zip cpython-06e1701ad3956352bc0f42b8f51c2f8cc85bf378.tar.gz cpython-06e1701ad3956352bc0f42b8f51c2f8cc85bf378.tar.bz2 | |
bpo-46556: emit `DeprecationWarning` from `pathlib.Path.__enter__()` (GH-30971)
In Python 3.9, Path.__exit__() was made a no-op and has never been documented.
Co-authored-by: Brett Cannon <brett@python.org>
Diffstat (limited to 'Lib/test/test_pathlib.py')
| -rw-r--r-- | Lib/test/test_pathlib.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index ec2baca..f03fcbe 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1850,8 +1850,10 @@ class _BasePathTest(object): it = p.iterdir() it2 = p.iterdir() next(it2) - with p: - pass + # bpo-46556: path context managers are deprecated in Python 3.11. + with self.assertWarns(DeprecationWarning): + with p: + pass # Using a path as a context manager is a no-op, thus the following # operations should still succeed after the context manage exits. next(it) @@ -1859,8 +1861,9 @@ class _BasePathTest(object): p.exists() p.resolve() p.absolute() - with p: - pass + with self.assertWarns(DeprecationWarning): + with p: + pass def test_chmod(self): p = self.cls(BASE) / 'fileA' |
