def test_memprofile_throwException(self): def example_method(arg1, arg2): return arg1 + arg2 self.assertRaises( Exception, profile_mem.profile_memory_decorator('example_method', example_method))
def test_disable_memprofile_by_decorator(self): def example_method(arg1, arg2): return arg1 + arg2 decorator_method = profile_mem.profile_memory_decorator( 'example_method', example_method) profile_mem.modules_profiling_status['example_method'] = False rt = decorator_method(1, 2) self.assertEqual(profile_mem.h, None) self.assertEqual(3, rt)
def test_initiliaze_memprofile(self): profile_mem.h = profile_mem.hpy() def example_method(arg1, arg2): return arg1 + arg2 decorator_method = profile_mem.profile_memory_decorator( 'example_method', example_method) profile_mem.modules_profiling_status['example_method'] = True rt = decorator_method(1, 2) self.assertEqual(3, rt)
def test_memprofile_no_dumpfile(self): self.flags(healthnmon_log_dir='') def example_method(arg1, arg2): return arg1 + arg2 decorator_method = profile_mem.profile_memory_decorator( 'example_method', example_method) profile_mem.modules_profiling_status['example_method'] = True rt = decorator_method(1, 2) self.assertFalse(os.path.isfile(self.path_to_file)) self.assertEqual(3, rt)
def test_enable_memprofile_setref_True(self): profile_mem.setref = True def example_method(arg1, arg2): return arg1 + arg2 decorator_method = profile_mem.profile_memory_decorator( 'example_method', example_method) profile_mem.modules_profiling_status['example_method'] = True rt = decorator_method(1, 2) self.assertNotEqual(profile_mem.h, None) self.assertEqual(3, rt)
def test_memprofile_throwException(self): def example_method(arg1, arg2): return arg1 + arg2 self.assertRaises(Exception, profile_mem.profile_memory_decorator( 'example_method', example_method))