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

Method test_time

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

Source from the content-addressed store, hash-verified

663 self.assertEqual(called, {-2, -3})
664
665 def test_time(self):
666 called = []
667 def f(x):
668 called.append(x)
669 ip.push({'f':f})
670
671 # Test with an expression
672 with tt.AssertPrints("Wall time: "):
673 ip.run_line_magic("time", "f(5+9)")
674 self.assertEqual(called, [-14])
675 called[:] = []
676
677 # Test with a statement (different code path)
678 with tt.AssertPrints("Wall time: "):
679 ip.run_line_magic("time", "a = f(-3 + -2)")
680 self.assertEqual(called, [5])
681
682 def test_macro(self):
683 ip.push({'a':10})

Callers

nothing calls this directly

Calls 2

run_line_magicMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected