Skip to content

Commit fc07f86

Browse files
authored
gh-131234: Improve test_popen with more asserts (#131235)
1 parent 2250ab6 commit fc07f86

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Lib/test/test_popen.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,21 @@ def test_return_code(self):
5757
def test_contextmanager(self):
5858
with os.popen("echo hello") as f:
5959
self.assertEqual(f.read(), "hello\n")
60+
self.assertFalse(f.closed)
61+
self.assertTrue(f.closed)
6062

6163
def test_iterating(self):
6264
with os.popen("echo hello") as f:
6365
self.assertEqual(list(f), ["hello\n"])
66+
self.assertFalse(f.closed)
67+
self.assertTrue(f.closed)
6468

6569
def test_keywords(self):
66-
with os.popen(cmd="exit 0", mode="w", buffering=-1):
67-
pass
70+
with os.popen(cmd="echo hello", mode="r", buffering=-1) as f:
71+
self.assertEqual(f.read(), "hello\n")
72+
self.assertFalse(f.closed)
73+
self.assertTrue(f.closed)
74+
6875

6976
if __name__ == "__main__":
7077
unittest.main()

0 commit comments

Comments
 (0)