https://github.com/python/cpython/commit/fc07f863ee2a942dd96e1ca9edf049603fbb574e
commit: fc07f863ee2a942dd96e1ca9edf049603fbb574e
branch: main
author: sobolevn <m...@sobolevn.me>
committer: sobolevn <m...@sobolevn.me>
date: 2025-03-14T11:38:31Z
summary:

gh-131234: Improve `test_popen` with more asserts (#131235)

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 -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to