def test_pprint_compact(self):
with patch('sys.stdout', new_callable=StringIO) as mock_stdout:
# - test compact pprint-ing with 80x25 terminal
with patch.object(pythonrc.subprocess, 'check_output',
return_value='25 80'):
sys.displayhook(list(range(22)))
self.assertIn('20, 21]', sys.stdout.getvalue())
sys.displayhook(list(range(23)))
self.assertIn('21,\n 22]', sys.stdout.getvalue())
# - test compact pprint-ing with resized 100x25 terminal
with patch.object(pythonrc.subprocess, 'check_output',
return_value=('25 100')):
sys.displayhook(list(range(23)))
self.assertIn('21, 22]', sys.stdout.getvalue())
评论列表
文章目录