Skip to content

Commit 02e8f9d

Browse files
committed
fix: address comments better test for it
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
1 parent 53aa617 commit 02e8f9d

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Lib/test/test_pyrepl/test_unix_console.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,18 @@ def test_getheightwidth_with_invalid_environ(self, _os_write):
304304
os.environ = []
305305
self.assertIsInstance(console.getheightwidth(), tuple)
306306

307-
@unittest.skipUnless(sys.platform == "darwin", "requires OS X")
308-
def test_mac_with_invalid_environ(self, _os_write):
307+
@unittest.skipUnless(sys.platform == "darwin", "requires OS X")
308+
def test_is_mac_with_invalid_environ(self, _os_write):
309309
# gh-128636 for macOS
310310
console = UnixConsole(term="xterm")
311311
with os_helper.EnvironmentVarGuard() as env:
312312
is_mac = os.getenv("TERM_PROGRAM") == "Apple_Terminal"
313313
self.assertEqual(console.is_mac, is_mac)
314314
os.environ = []
315-
self.assertIsInstance(console.getheightwidth(), tuple)
315+
console.prepare() # Need to prepare before restore
316+
try:
317+
console.restore() # This should not crash
318+
except (KeyError, AttributeError, TypeError) as e:
319+
self.fail(f"restore() failed with invalid environ: {e}")
320+
321+
self.assertEqual(console.is_mac, is_mac)

0 commit comments

Comments
 (0)