def decorative_conditional(): """@Tests().register_if(condition)(TestBase)""" col = Tests() class IncludedTest(TestBase): @test def foo(self): pass @test def bar(self): pass class ExcludedTest(TestBase): @test def spam(self): pass @test def eggs(self): pass col.register_if(True)(IncludedTest) col.register_if(False)(ExcludedTest) assert len(col) == 2 assert sorted(test.__name__ for test in col) == ['bar', 'foo']