https://github.com/python/cpython/commit/1d6d33c33f9a7df675e83d4d2ae82997188461e8 commit: 1d6d33c33f9a7df675e83d4d2ae82997188461e8 branch: main author: Serhiy Storchaka <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-06-27T01:45:30+03:00 summary:
gh-152260: Fix test_scr_dump() on macOS (GH-152340) The dump format embeds raw pointers on some platforms, so two dumps of the same screen are not always byte-identical. Only compare dump files when the format proves deterministic. Co-authored-by: Claude Opus 4.8 <[email protected]> files: M Lib/test/test_curses.py diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 7157896d8cbccd..a16279e5f39411 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -1129,21 +1129,27 @@ def test_scr_dump(self): with tempfile.TemporaryDirectory() as d: dump = os.path.join(d, 'dump') self.assertIsNone(curses.scr_dump(dump)) - # Dumping the same screen again is deterministic. + with open(dump, 'rb') as f: + image = f.read() + self.assertTrue(image) + # The dump format embeds raw pointers on some platforms (such as + # macOS), so two dumps of the same screen are not always identical. + # Only compare dump files when the format proves deterministic. dump2 = os.path.join(d, 'dump2') curses.scr_dump(dump2) - with open(dump, 'rb') as f1, open(dump2, 'rb') as f2: - self.assertEqual(f1.read(), f2.read()) + with open(dump2, 'rb') as f: + deterministic = f.read() == image # scr_restore() reloads that virtual screen, so dumping it again # reproduces the original file even after the screen has changed. stdscr.erase() stdscr.addstr(0, 0, 'something else') stdscr.refresh() self.assertIsNone(curses.scr_restore(dump)) - restored = os.path.join(d, 'restored') - curses.scr_dump(restored) - with open(dump, 'rb') as f1, open(restored, 'rb') as f2: - self.assertEqual(f1.read(), f2.read()) + if deterministic: + restored = os.path.join(d, 'restored') + curses.scr_dump(restored) + with open(restored, 'rb') as f: + self.assertEqual(f.read(), image) # scr_init() and scr_set() accept a dump file and return None. self.assertIsNone(curses.scr_init(dump)) self.assertIsNone(curses.scr_set(dump)) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
