MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / test_tqdm_write

Method test_tqdm_write

test/null/test_tqdm.py:277–289  ·  view source on GitHub ↗
(self, mock_terminal_size, mock_stderr)

Source from the content-addressed store, hash-verified

275 @patch('sys.stderr', new_callable=StringIO)
276 @patch('shutil.get_terminal_size')
277 def test_tqdm_write(self, mock_terminal_size, mock_stderr):
278 for _ in range(5):
279 ncols, tqdm_fp = random.randint(*NCOLS_RANGE), StringIO()
280 mock_terminal_size.return_value = namedtuple(field_names='columns', typename='terminal_size')(ncols)
281 mock_stderr.truncate(0)
282 tqdm_fp.truncate(0)
283 for i in tinytqdm(range(10)):
284 time.sleep(0.01)
285 tinytqdm.write(str(i))
286 tqdm.write(str(i), file=tqdm_fp)
287 tinytqdm_out, tqdm_out = mock_stderr.getvalue(), tqdm_fp.getvalue()
288 self.assertEqual(tinytqdm_out.split("\r\033[K")[-1], tqdm_out.split(f"{i-1}\n")[-1])
289 self.assertEqual(tinytqdm_out, tinytqdm_out)
290
291 @patch('sys.stderr', new_callable=StringIO)
292 @patch('shutil.get_terminal_size')

Callers

nothing calls this directly

Calls 4

randintMethod · 0.80
splitMethod · 0.80
sleepMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected