bpo-39682: make pathlib.Path immutable by removing (undocumented) support for "closing" a path by using it as a context manager (GH-18846)

Support for using a path as a context manager remains, and is now a no-op.
This commit is contained in:
Barney Gale 2020-04-01 15:10:51 +01:00 committed by GitHub
parent 975ac326ff
commit 00002e6d8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 49 deletions

View file

@ -1720,13 +1720,15 @@ class _BasePathTest(object):
next(it2)
with p:
pass
# I/O operation on closed path.
self.assertRaises(ValueError, next, it)
self.assertRaises(ValueError, next, it2)
self.assertRaises(ValueError, p.open)
self.assertRaises(ValueError, p.resolve)
self.assertRaises(ValueError, p.absolute)
self.assertRaises(ValueError, p.__enter__)
# 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)
next(it2)
p.exists()
p.resolve()
p.absolute()
with p:
pass
def test_chmod(self):
p = self.cls(BASE) / 'fileA'