def testcase_naming(): example = Tests() @example.test def simple(): pass @example.test def simple(): """Duplicate name, should have ``_2`` appended.""" class Test(TestBase): @test def simple(): """Another duplicate, should have ``_3`` appended.""" Test = example.register(Test) # Python 2.5 @example.test def test_something(): """Already prepended with ``test_`` - should be used verbatim.""" example.test(lambda self: None) TestCase = example.test_case() assert TestCase.test_simple assert TestCase.test_simple_2 assert TestCase.test_simple_3 assert TestCase.test_something assert TestCase.test_lambda
def unittest(): """Compatibility with Python's unittest package""" signals = set() example = Tests() @example.test def simple(): signals.add("one") class Test(TestBase): @test def simple(self): signals.add("two") Test = example.register(Test) # Python 2.5 # unittest.TestCase TestCase = example.test_case() TestCase("test_simple").debug() assert signals == set(["one"]) # unittest.TestSuite test_suite = example.test_suite() signals.clear() test_suite.debug() assert signals == set(["one", "two"])