def test_without_builtins(self): requires_yappi() cpu.start() dict() cpu.stop() stats = open_ystats(FILENAME) self.assertFalse(find_module(stats, '__builtin__'))
def test_fail_if_Profile_is_running(self): requires_yappi() cpu.start() try: self.assertRaises(cpu.Error, self.profiled_function) finally: cpu.stop()
def test_ystats_format(self): requires_yappi() with env(format='ystat') as filename: cpu.start() cpu.is_running() # Let if profile something cpu.stop() self.assertNotRaises(open_ystats, filename)
def test_disabled(self): with env(enable='false'): cpu.start() try: self.assertFalse(cpu.is_running()) finally: cpu.stop()
def test_without_builtins(self): requires_yappi() with env(format='ystat', builtins='false') as filename: cpu.start() dict() cpu.stop() stats = open_ystats(filename) self.assertFalse(find_module(stats, '__builtin__'))
def test_is_running(self): requires_yappi() self.assertFalse(cpu.is_running()) cpu.start() try: self.assertTrue(cpu.is_running()) finally: cpu.stop() self.assertFalse(cpu.is_running())
def test_wall_clock(self): requires_yappi() cpu.start() self.sleep(0.1) cpu.stop() stats = open_ystats(FILENAME) name = function_name(self.sleep) func = find_function(stats, __file__, name) self.assertTrue(func.ttot > 0.1)
def test_cpu_clock(self): requires_yappi() with env(format='ystat', clock='cpu', builtins='false') as filename: cpu.start() self.sleep(0.1) cpu.stop() stats = open_ystats(filename) name = function_name(self.sleep) func = find_function(stats, __file__, name) self.assertTrue(func.ttot < 0.1)
def test_fail_if_Profile_is_running(self): requires_yappi() with env(enable='true') as filename: @cpu.profile(filename) def profiled_function(): self.assertTrue(cpu.is_running()) cpu.start() try: self.assertRaises(UsageError, profiled_function) finally: cpu.stop()
def test_disabled(self): cpu.start() try: self.assertFalse(cpu.is_running()) finally: cpu.stop()
def test_ystats_format(self): requires_yappi() cpu.start() cpu.is_running() # Let if profile something cpu.stop() self.assertNotRaises(open_ystats, FILENAME)