FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.12] gh-131234: Improve `test_popen` with more asserts (GH-131235) by miss-islington · Pull Request #131241 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 9 additions & 2 deletions Lib/test/test_popen.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Back | FazBrowse Home | New Git URL