MCPcopy Index your code
hub / github.com/python/cpython / test_stty_match

Method test_stty_match

Lib/test/test_shutil.py:3464–3482  ·  view source on GitHub ↗

Check if stty returns the same results ignoring env This test will fail if stdin and stdout are connected to different terminals with different sizes. Nevertheless, such situations should be pretty rare.

(self)

Source from the content-addressed store, hash-verified

3462 @unittest.skipUnless(hasattr(os, 'get_terminal_size'),
3463 'need os.get_terminal_size()')
3464 def test_stty_match(self):
3465 """Check if stty returns the same results ignoring env
3466
3467 This test will fail if stdin and stdout are connected to
3468 different terminals with different sizes. Nevertheless, such
3469 situations should be pretty rare.
3470 """
3471 try:
3472 size = subprocess.check_output(['stty', 'size']).decode().split()
3473 except (FileNotFoundError, PermissionError,
3474 subprocess.CalledProcessError):
3475 self.skipTest("stty invocation failed")
3476 expected = (int(size[1]), int(size[0])) # reversed order
3477
3478 with os_helper.EnvironmentVarGuard() as env:
3479 env.unset('LINES', 'COLUMNS')
3480 actual = shutil.get_terminal_size()
3481
3482 self.assertEqual(expected, actual)
3483
3484 @unittest.skipIf(support.is_wasi, "WASI has no /dev/null")
3485 def test_fallback(self):

Callers

nothing calls this directly

Calls 6

skipTestMethod · 0.80
unsetMethod · 0.80
splitMethod · 0.45
decodeMethod · 0.45
check_outputMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected