mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-133982: Run unclosed file test on all io implementations (gh-134165)
Update `test_io` `_check_warn_on_dealloc` to use `self.` to dispatch to different I/O implementations. Update the `_pyio` implementation to match expected behavior, using the same `_dealloc_warn` design as the C implementation uses to report the topmost `__del__` object. The FileIO one now matches all the others, so can use IOBase. There was a missing check on closing (self._fd must be valid), add that check
This commit is contained in:
parent
06eaf4055c
commit
5b0e827521
3 changed files with 19 additions and 6 deletions
|
@ -4417,7 +4417,7 @@ class MiscIOTest(unittest.TestCase):
|
|||
self._check_abc_inheritance(io)
|
||||
|
||||
def _check_warn_on_dealloc(self, *args, **kwargs):
|
||||
f = open(*args, **kwargs)
|
||||
f = self.open(*args, **kwargs)
|
||||
r = repr(f)
|
||||
with self.assertWarns(ResourceWarning) as cm:
|
||||
f = None
|
||||
|
@ -4446,7 +4446,7 @@ class MiscIOTest(unittest.TestCase):
|
|||
r, w = os.pipe()
|
||||
fds += r, w
|
||||
with warnings_helper.check_no_resource_warning(self):
|
||||
open(r, *args, closefd=False, **kwargs)
|
||||
self.open(r, *args, closefd=False, **kwargs)
|
||||
|
||||
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
|
||||
def test_warn_on_dealloc_fd(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue