mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-131234: Improve test_popen
with more asserts (#131235)
This commit is contained in:
parent
2250ab6a13
commit
fc07f863ee
1 changed files with 9 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue