diff options
author | Benjamin Peterson <benjamin@python.org> | 2017-12-29 21:13:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-29 21:13:06 (GMT) |
commit | bbdb17d19bb1d5443ca4417254e014ad64c04540 (patch) | |
tree | fc518799f5fedc84812666d3994fa19aec5f2f8d /Lib | |
parent | 03220fdb26c0b6a50ce5ed1fdfbf232094b66db6 (diff) | |
download | cpython-bbdb17d19bb1d5443ca4417254e014ad64c04540.zip cpython-bbdb17d19bb1d5443ca4417254e014ad64c04540.tar.gz cpython-bbdb17d19bb1d5443ca4417254e014ad64c04540.tar.bz2 |
return the new file descriptor from os.dup2 (closes bpo-32441) (#5041)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_os.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index f235f80..83e214d 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -3079,19 +3079,15 @@ class FDInheritanceTests(unittest.TestCase): # inheritable by default fd2 = os.open(__file__, os.O_RDONLY) - try: - os.dup2(fd, fd2) - self.assertEqual(os.get_inheritable(fd2), True) - finally: - os.close(fd2) + self.addCleanup(os.close, fd2) + self.assertEqual(os.dup2(fd, fd2), fd2) + self.assertTrue(os.get_inheritable(fd2)) # force non-inheritable fd3 = os.open(__file__, os.O_RDONLY) - try: - os.dup2(fd, fd3, inheritable=False) - self.assertEqual(os.get_inheritable(fd3), False) - finally: - os.close(fd3) + self.addCleanup(os.close, fd3) + self.assertEqual(os.dup2(fd, fd3, inheritable=False), fd3) + self.assertFalse(os.get_inheritable(fd3)) @unittest.skipUnless(hasattr(os, 'openpty'), "need os.openpty()") def test_openpty(self): |