Example #1
0
 def test_without_builtins(self):
     requires_yappi()
     cpu.start()
     dict()
     cpu.stop()
     stats = open_ystats(FILENAME)
     self.assertFalse(find_module(stats, '__builtin__'))
Example #2
0
 def test_fail_if_Profile_is_running(self):
     requires_yappi()
     cpu.start()
     try:
         self.assertRaises(cpu.Error, self.profiled_function)
     finally:
         cpu.stop()
Example #3
0
 def test_without_builtins(self):
     requires_yappi()
     cpu.start()
     dict()
     cpu.stop()
     stats = open_ystats(FILENAME)
     self.assertFalse(find_module(stats, '__builtin__'))
Example #4
0
 def test_fail_if_Profile_is_running(self):
     requires_yappi()
     cpu.start()
     try:
         self.assertRaises(cpu.Error, self.profiled_function)
     finally:
         cpu.stop()
Example #5
0
 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)
Example #6
0
 def test_disabled(self):
     with env(enable='false'):
         cpu.start()
         try:
             self.assertFalse(cpu.is_running())
         finally:
             cpu.stop()
Example #7
0
 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__'))
Example #8
0
 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())
Example #9
0
 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)
Example #10
0
 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())
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
    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()
Example #14
0
 def test_disabled(self):
     cpu.start()
     try:
         self.assertFalse(cpu.is_running())
     finally:
         cpu.stop()
Example #15
0
 def test_ystats_format(self):
     requires_yappi()
     cpu.start()
     cpu.is_running()  # Let if profile something
     cpu.stop()
     self.assertNotRaises(open_ystats, FILENAME)
Example #16
0
 def test_disabled(self):
     cpu.start()
     try:
         self.assertFalse(cpu.is_running())
     finally:
         cpu.stop()
Example #17
0
 def test_ystats_format(self):
     requires_yappi()
     cpu.start()
     cpu.is_running()  # Let if profile something
     cpu.stop()
     self.assertNotRaises(open_ystats, FILENAME)