From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 14 Mar 2025 12:02:47 +0000 (+0100) Subject: [3.13] gh-131234: Improve `test_popen` with more asserts (GH-131235) (#131240) X-Git-Tag: v3.13.3~127 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3ca70c5279274a739a9d29c05dfde031549021b;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-131234: Improve `test_popen` with more asserts (GH-131235) (#131240) gh-131234: Improve `test_popen` with more asserts (GH-131235) (cherry picked from commit fc07f863ee2a942dd96e1ca9edf049603fbb574e) Co-authored-by: sobolevn --- diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py index e6bfc480cbd1..34cda35b17bd 100644 --- a/Lib/test/test_popen.py +++ b/Lib/test/test_popen.py @@ -57,14 +57,21 @@ class PopenTest(unittest.TestCase): 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()