def test_expectDecoUniqueness(self): @frep.deco() def foo(): pass @frep.deco() def bar(): pass self.assertNotEqual(frep.getDeco('foo'), frep.getDeco('bar'))
def test_unsuccessfulExecution(self): @deco(profiler=PidStatProfiler()) def canNotFail(): return [(10 / i, time.sleep(0.73)) for i in xrange(4, -1, -1)] self.assertRaises(Exception, canNotFail) p = getDeco('canNotFail').p self._expectFileCreated(p.filePath) self._expectTokenAtBeginning(p.filePath) self._expectTokenAtEnd(p.filePath) self._expectGuts(p.filePath) os.remove(p.filePath)
def test_successfulExecution(self): @deco(profiler=PidStatProfiler()) def slowFunction(): for i in xrange(2): time.sleep(0.79) slowFunction() p = getDeco('slowFunction').p self._expectFileCreated(p.filePath) self._expectTokenAtBeginning(p.filePath) self._expectTokenAtEnd(p.filePath) self._expectGuts(p.filePath) os.remove(p.filePath)
def test_modifyProfilerAtRuntime(self): deco = frep.getDeco('meth') d = dict() deco.p = P(d) SUT().meth(10) self.assertTrue(d['called'])
def test_getDecoByOriginalMethodName(self): self.assertTrue(frep.getDeco('meth'))
def test_getDecoByOriginalFunctionName(self): self.assertTrue(frep.getDeco('sut'))