Пример #1
0
def test_load_suite_from_class_suites_order():
    @lcc.suite("suite")
    class suite:
        @lcc.suite("a")
        class a:
            @lcc.test("test")
            def test(self):
                pass

        @lcc.suite("d")
        class d:
            @lcc.test("test")
            def test(self):
                pass

        @lcc.suite("c")
        class c:
            @lcc.test("test")
            def test(self):
                pass

        @lcc.suite("b")
        class b:
            @lcc.test("test")
            def test(self):
                pass

    suite = load_suite_from_class(suite)
    suites = suite.get_suites()

    assert suites[0].name == "a"
    assert suites[1].name == "d"
    assert suites[2].name == "c"
    assert suites[3].name == "b"
Пример #2
0
def test_load_suite_from_class_tests_order():
    @lcc.suite("suite")
    class suite:
        @lcc.test("a")
        def a(self):
            pass

        @lcc.test("d")
        def d(self):
            pass

        @lcc.test("c")
        def c(self):
            pass

        @lcc.test("b")
        def b(self):
            pass

    suite = load_suite_from_class(suite)
    tests = suite.get_tests()

    assert tests[0].name == "a"
    assert tests[1].name == "d"
    assert tests[2].name == "c"
    assert tests[3].name == "b"
Пример #3
0
def test_load_suite_from_class_with_fixture_dependencies():
    @lcc.suite("mysuite")
    class Suite:
        foo = lcc.inject_fixture()

    suite = load_suite_from_class(Suite)
    fixture_names = suite.get_fixtures()
    assert fixture_names == ["foo"]
Пример #4
0
def test_load_suite_class_with_property():
    @lcc.suite("mysuite")
    class mysuite(object):
        @lcc.test("mytest")
        def mytest(self):
            pass

        @property
        def myprop(self):
            # ensure that myprop is not called:
            assert False

    suite = load_suite_from_class(mysuite)
    assert len(suite.get_tests()) == 1
Пример #5
0
def test_load_suite_from_class_with_hooks():
    @lcc.suite("mysuite")
    class Suite:
        def setup_suite(self):
            return 1

        def teardown_suite(self):
            return 2

        def setup_test(self, test):
            return 3

        def teardown_test(self, test, status):
            return 4

        @lcc.test("some test")
        def sometest(self):
            pass

    suite = load_suite_from_class(Suite)
    assert suite.get_hook("setup_suite")() == 1
    assert suite.get_hook("teardown_suite")() == 2
    assert suite.get_hook("setup_test")(suite.get_tests()[0]) == 3
    assert suite.get_hook("teardown_test")(suite.get_tests()[0], "passed") == 4