def test_matching_result(self): if spells.timeit(repeat=2): sleep(1) result = 3 else: sleep(1.1) result = 3 self.assert_usual_output()
def test_exception(self): try: if spells.timeit(): print(1 / 0) else: pass except ZeroDivisionError: traceback.print_exc(file=sys.stdout) stdout = sys.stdout.getvalue() self.assertIn('<timeit-src>', stdout) self.assertIn('1 / 0', stdout)
def test_not_matching_result(self): with self.assertRaises(AssertionError): if spells.timeit(): result = 3 else: result = 4
def test_no_result(self): if spells.timeit(repeat=2): sleep(1) else: sleep(1.1) self.assert_usual_output()
def test_timeit_in_function(self): with self.assertRaises(ValueError): spells.timeit()