Пример #1
0
    def test_makeTest_makes_tests_from_test_case_class(self):
        class SomeTests(MAASTestCase):
            test_a = lambda self: None
            test_b = lambda self: None

        tests = self.makeTest(Scenarios(), SomeTests, self)

        self.assertThat(tests, HasLength(2))
        self.assertThat(tests, AllMatch(IsInstance(SomeTests)))
        self.assertThat({test._testMethodName
                         for test in tests}, Equals({"test_a", "test_b"}))
Пример #2
0
    def test_makeTest_makes_tests_from_test_function(self):
        class SomeTests(MAASTestCase):
            def test_a(self):
                """Example test method."""

            def test_b(self):
                """Example test method."""

        method = random.choice((SomeTests.test_a, SomeTests.test_b))
        tests = self.makeTest(Scenarios(), method, SomeTests)

        self.assertThat(tests, HasLength(1))
        self.assertThat(tests, AllMatch(IsInstance(SomeTests)))
        self.assertThat({test._testMethodName
                         for test in tests}, Equals({method.__name__}))
Пример #3
0
    def test_makeTest_makes_tests_from_test_case_class_with_scenarios(self):
        class SomeTests(MAASTestCase):
            scenarios = [("scn1", {"attr": 1}), ("scn2", {"attr": 2})]
            test_a = lambda self: None
            test_b = lambda self: None

        tests = self.makeTest(Scenarios(), SomeTests, self)

        self.assertThat(tests, HasLength(4))
        self.assertThat(tests, AllMatch(IsInstance(SomeTests)))
        self.assertThat(
            {(test._testMethodName, test.attr) for test in tests},
            Equals(
                {("test_a", 1), ("test_a", 2), ("test_b", 1), ("test_b", 2)}
            ),
        )
Пример #4
0
    def test_makeTest_makes_tests_from_test_function_with_scenarios(self):
        class SomeTests(MAASTestCase):
            scenarios = [("scn1", {"attr": 1}), ("scn2", {"attr": 2})]

            def test_a(self):
                """Example test method."""

            def test_b(self):
                """Example test method."""

        method = random.choice((SomeTests.test_a, SomeTests.test_b))
        tests = self.makeTest(Scenarios(), method, SomeTests)

        self.assertThat(tests, HasLength(2))
        self.assertThat(tests, AllMatch(IsInstance(SomeTests)))
        self.assertThat({(test._testMethodName, test.attr)
                         for test in tests},
                        Equals({(method.__name__, 1), (method.__name__, 2)}))