MCPcopy Create free account
hub / github.com/ipython/ipython / test_timeit

Method test_timeit

IPython/core/tests/test_interactiveshell.py:758–771  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

756 self.assertEqual(ip.user_ns['o'], 2.0)
757
758 def test_timeit(self):
759 called = set()
760 def f(x):
761 called.add(x)
762 ip.push({'f':f})
763
764 with tt.AssertPrints("std. dev. of"):
765 ip.run_line_magic("timeit", "-n1 f(1)")
766 self.assertEqual(called, {(1,)})
767 called.clear()
768
769 with tt.AssertPrints("std. dev. of"):
770 ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)")
771 self.assertEqual(called, {(2,), (3,)})
772
773class ErrorTransformer(ast.NodeTransformer):
774 """Throws an error when it sees a number."""

Callers

nothing calls this directly

Calls 3

run_line_magicMethod · 0.80
run_cell_magicMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected