Beispiel #1
0
    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')
Beispiel #2
0
    def test_to_str(self):
        rule_1 = suite.BuildRule(
            'package.module',
            case_name='ClassName',
            test_name='method_name',
        )
        rule_2 = suite.BuildRule(
            'package.module',
            case_name='ClassName',
        )
        rule_3 = suite.BuildRule('package.module', )

        self.assertEqual(str(rule_1), 'package.module:ClassName.method_name')
        self.assertEqual(str(rule_2), 'package.module:ClassName')
        self.assertEqual(str(rule_3), 'package.module')
Beispiel #3
0
    def test_basic(self):
        rule = suite.BuildRule(
            'package.module',
            case_name='ClassName',
            test_name='method_name',
        )

        self.assertEqual(rule.suite_name, 'package.module')
        self.assertEqual(rule.case_name, 'ClassName')
        self.assertEqual(rule.test_name, 'method_name')
Beispiel #4
0
    def test_repr(self):
        rule = suite.BuildRule(
            'package.module',
            case_name='ClassName',
            test_name='method_name',
        )

        self.assertEqual(
            repr(rule),
            '<BuildRule(suite_name=package.module, case_name=ClassName, test_name=method_name)>',
        )
Beispiel #5
0
    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',
        )
Beispiel #6
0
    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'])
Beispiel #7
0
    def test_is_of_negative(self):
        suite_inst = suite.Suite(__name__)
        rule = suite.BuildRule('package.module')

        self.assertFalse(rule.is_of(suite_inst))
Beispiel #8
0
    def test_is_of(self):
        suite_inst = suite.Suite(__name__)
        rule = suite.BuildRule(__name__)

        self.assertTrue(rule.is_of(suite_inst))
Beispiel #9
0
        self.assertEqual(len(boxes), 1)
        self.assertIsInstance(boxes[0], self.suite.__case_box_class__)

    def test_build_by_rule(self):
        @self.suite.register
        class CaseClass(case.Case):
            def test(self):
                pass

        @self.suite.register
        class CaseClass2(case.Case):
            def test(self):
                pass

        self.suite.assign_build_rule(
            suite.BuildRule(self.suite.name, case_name=CaseClass.__name__))

        self.suite.build()

        boxes = [c for c in self.suite]

        self.assertEqual(len(boxes), 1)
        self.assertIsInstance(boxes[0], self.suite.__case_box_class__)

    def test_case_name_param(self):
        @self.suite.register
        class CaseClass(case.Case):
            def test(self):
                pass

        @self.suite.register
Beispiel #10
0
 def setUp(self):
     self.fake_rule_a = suite.BuildRule('a', case_name='b', test_name='c')
     self.fake_rule_b = suite.BuildRule('x', case_name='y', test_name='z')
     self.rules = [self.fake_rule_a, self.fake_rule_b]