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

Method test_fallback

Lib/test/test_shutil.py:3485–3501  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3483
3484 @unittest.skipIf(support.is_wasi, "WASI has no /dev/null")
3485 def test_fallback(self):
3486 with os_helper.EnvironmentVarGuard() as env:
3487 env.unset('LINES', 'COLUMNS')
3488
3489 # sys.__stdout__ has no fileno()
3490 with support.swap_attr(sys, '__stdout__', None):
3491 size = shutil.get_terminal_size(fallback=(10, 20))
3492 self.assertEqual(size.columns, 10)
3493 self.assertEqual(size.lines, 20)
3494
3495 # sys.__stdout__ is not a terminal on Unix
3496 # or fileno() not in (0, 1, 2) on Windows
3497 with open(os.devnull, 'w', encoding='utf-8') as f, \
3498 support.swap_attr(sys, '__stdout__', f):
3499 size = shutil.get_terminal_size(fallback=(30, 40))
3500 self.assertEqual(size.columns, 30)
3501 self.assertEqual(size.lines, 40)
3502
3503
3504class PublicAPITests(unittest.TestCase):

Callers

nothing calls this directly

Calls 3

unsetMethod · 0.80
openFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected