https://github.com/python/cpython/commit/9a612a850cc0de1a3956ecb2af59010e30adce04 commit: 9a612a850cc0de1a3956ecb2af59010e30adce04 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: sobolevn <[email protected]> date: 2025-03-14T11:54:56Z summary:
[3.12] gh-131234: Improve `test_popen` with more asserts (GH-131235) (#131241) gh-131234: Improve `test_popen` with more asserts (GH-131235) (cherry picked from commit fc07f863ee2a942dd96e1ca9edf049603fbb574e) Co-authored-by: sobolevn <[email protected]> files: M Lib/test/test_popen.py diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py index e6bfc480cbd12c..34cda35b17bdb0 100644 --- a/Lib/test/test_popen.py +++ b/Lib/test/test_popen.py @@ -57,14 +57,21 @@ def test_return_code(self): def test_contextmanager(self): with os.popen("echo hello") as f: self.assertEqual(f.read(), "hello\n") + self.assertFalse(f.closed) + self.assertTrue(f.closed) def test_iterating(self): with os.popen("echo hello") as f: self.assertEqual(list(f), ["hello\n"]) + self.assertFalse(f.closed) + self.assertTrue(f.closed) def test_keywords(self): - with os.popen(cmd="exit 0", mode="w", buffering=-1): - pass + with os.popen(cmd="echo hello", mode="r", buffering=-1) as f: + self.assertEqual(f.read(), "hello\n") + self.assertFalse(f.closed) + self.assertTrue(f.closed) + if __name__ == "__main__": unittest.main() _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
