def test_exclude(self): config_inst = config_factory.create(EXCLUDE_SUITE_PATTERN=r'^program.*$') program_inst = program_factory.create(config_inst) suite_one = suite.Suite('package.module') suite_two = suite.Suite('program.module') self.assertTrue(program_inst.suite_is_valid(suite_one)) self.assertFalse(program_inst.suite_is_valid(suite_two))
def setUp(self): self.fake_rule_1 = suite.BuildRule('package.cool_module') self.fake_rule_2 = suite.BuildRule('package.cool_module') self.fake_rule_01 = suite.BuildRule('package.cool_module01') self.different_packages_rules = [ self.fake_rule_1, self.fake_rule_2, self.fake_rule_01 ] self.similar_packages_rules = [self.fake_rule_01] self.fake_suite_1 = suite.Suite('package.cool_module') self.fake_suite_01 = suite.Suite('package.cool_module01')
def test_add_teardown_callback(self): teardown = lambda: None suite_inst = suite.Suite(__name__) suite_inst.add_teardown(teardown) self.assertIn(teardown, suite_inst.context.teardown_callbacks)
def test_add_setup_callback(self): setup = lambda: None suite_inst = suite.Suite(__name__) suite_inst.add_setup(setup) self.assertIn(setup, suite_inst.context.setup_callbacks)
def test_register_suites(self): program_inst = program.Program() suite_inst = suite.Suite('test') program_inst.register_suites([suite_inst]) self.assertIn(suite_inst, program_inst.suites)
def test_create_reason(self): suite_inst = suite.Suite(__name__) suite_inst.reason_storage['hello'] = 'world' reason = suite_inst.__reason__() self.assertEqual( reason, 'Suite (info from suite): \n hello: world\n\n', )
def test_not_mount(self): suite_inst = suite.Suite(__name__) with self.assertRaises(AssertionError) as ctx: suite_inst.build() self.assertEqual( pyv.get_exc_message(ctx.exception), 'Can not call "build" of "seismograph.suite.Suite". Should be mount.', )
def test_assign_incorrect_build_rule(self): suite_inst = suite.Suite(__name__) rule = suite.BuildRule('incorrect.name', case_name='MyTestCase') with self.assertRaises(AssertionError) as ctx: suite_inst.assign_build_rule(rule) self.assertEqual( pyv.get_exc_message(ctx.exception), 'Build rule "incorrect.name:MyTestCase" is not of this suite', )
def test_assign_build_rule(self): layer = layers.SuiteLayer() suite_inst = suite.Suite(__name__, layers=[layer]) rule = suite.BuildRule(__name__, case_name='MyTestCase', test_name='test') suite_inst.assign_build_rule(rule) self.assertIn(rule, suite_inst.context.build_rules) self.assertEqual(layer.calling_story, ['on_init', 'on_require', 'on_build_rule'])
def runTest(self): case_layer = layers.CaseLayer() suite_layer = layers.SuiteLayer() program_layer = layers.ProgramLayer() suite_inst = suite.Suite('test', layers=[suite_layer]) @suite_inst.register(layers=[case_layer]) class TestOne(case.Case): def test(self): pass
def test_init(self): layer = SuiteLayer() suite_inst = suite.Suite(__name__, require=['hello'], layers=[layer]) self.assertEqual(suite_inst.name, __name__) self.assertEqual(suite_inst.cases, []) self.assertIn(layer, suite_inst.context.layers) self.assertEqual(suite_inst.context.require, ['hello']) self.assertEqual( str(suite_inst), '<seismograph.suite.Suite method_name=run stopped_on=run>', ) self.assertEqual( repr(suite_inst), '<seismograph.suite.Suite method_name=run stopped_on=run>', )
def test_is_of_negative(self): suite_inst = suite.Suite(__name__) rule = suite.BuildRule('package.module') self.assertFalse(rule.is_of(suite_inst))
def test_is_of(self): suite_inst = suite.Suite(__name__) rule = suite.BuildRule(__name__) self.assertTrue(rule.is_of(suite_inst))
def test_basic(self): program_inst = program.Program() suite_inst = suite.Suite('package.module') self.assertTrue(program_inst.suite_is_valid(suite_inst))