| 2592 | self.assertEqual(f.read(), "foobar") |
| 2593 | |
| 2594 | def test_newline(self): |
| 2595 | # Test with explicit newline (universal newline mode disabled). |
| 2596 | text = THIS_FILE_STR.replace(os.linesep, "\n") |
| 2597 | with io.BytesIO() as bio: |
| 2598 | with open(bio, "wt", encoding="utf-8", newline="\n") as f: |
| 2599 | f.write(text) |
| 2600 | bio.seek(0) |
| 2601 | with open(bio, "rt", encoding="utf-8", newline="\r") as f: |
| 2602 | self.assertEqual(f.readlines(), [text]) |
| 2603 | |
| 2604 | def test_x_mode(self): |
| 2605 | with tempfile.NamedTemporaryFile(delete=False) as tmp_f: |