Beispiel #1
0
def test_test_success():
    @lcc.suite("MySuite")
    class MySuite:
        @lcc.test("Some test")
        def sometest(self):
            pass

    assert_test_passed(run_suite_class(MySuite))
Beispiel #2
0
def test_test_module():
    suite = build_suite_from_module("""
@lcc.test("Some test")
def sometest():
    pass
""")

    report = run_suite(suite)
    assert_test_passed(report)
Beispiel #3
0
def test_sub_suite_inline():
    @lcc.suite("MyParentSuite")
    class MyParentSuite:
        @lcc.suite("MyChildSuite")
        class MyChildSuite:
            @lcc.test("Some test")
            def sometest(self):
                pass

    assert_test_passed(run_suite_class(MyParentSuite))
Beispiel #4
0
def test_generated_test():
    @lcc.suite("MySuite")
    class MySuite:
        def __init__(self):
            def test_func():
                lcc.log_info("somelog")

            test = lcc.Test("mytest", "My Test", test_func)
            add_test_into_suite(test, self)

    assert_test_passed(run_suite_class(MySuite))
Beispiel #5
0
def test_session_prerun_fixture_teardown_user_error():
    @lcc.fixture(scope="session_prerun")
    def fix():
        yield
        raise lcc.UserError("some error")

    @lcc.suite("MySuite")
    class MySuite:
        @lcc.test("Some test")
        def sometest(self, fix):
            pass

    with pytest.raises(LemonCheesecakeException) as excinfo:
        report = run_suite_class(MySuite, fixtures=[fix])
        assert str(excinfo.value) == "some error"
        assert_test_passed(report)
Beispiel #6
0
def test_session_prerun_fixture_teardown_exception():
    @lcc.fixture(scope="session_prerun")
    def fix():
        yield
        1 / 0

    @lcc.suite("MySuite")
    class MySuite:
        @lcc.test("Some test")
        def sometest(self, fix):
            pass

    with pytest.raises(LemonCheesecakeException) as excinfo:
        report = run_suite_class(MySuite, fixtures=[fix])
        assert "Got an unexpected" in str(excinfo.value)
        assert_test_passed(report)
Beispiel #7
0
def test_teardown_suite_error_because_of_error_log():
    @lcc.suite("MySuite")
    class MySuite:
        @lcc.test("Some test")
        def sometest(self):
            pass

        def teardown_suite(self):
            lcc.log_error("some error")

    report = run_suite_class(MySuite)

    assert_test_passed(report)
    assert_report_node_success(report,
                               TreeLocation.in_suite_teardown("MySuite"),
                               expected=False)
Beispiel #8
0
def test_run_with_fixture_injected_in_class():
    marker = []

    @lcc.fixture(scope="session")
    def fixt1():
        return 1

    @lcc.suite("MySuiteA")
    class MySuite:
        fixt1 = lcc.inject_fixture()

        @lcc.test("sometest")
        def sometest(self):
            marker.append(self.fixt1)

    report = run_suite_class(MySuite, fixtures=[fixt1])

    assert_test_passed(report)
    assert marker == [1]
Beispiel #9
0
def test_teardown_suite_error_because_of_fixture():
    marker = []

    @lcc.fixture(scope="suite")
    def fix():
        yield 2
        1 / 0

    @lcc.suite("MySuite")
    class MySuite:
        @lcc.test("Some test")
        def sometest(self, fix):
            pass

        def teardown_suite(self):
            marker.append("teardown")

    report = run_suite_class(MySuite, fixtures=[fix])

    assert_test_passed(report)
    assert_report_node_success(report,
                               TreeLocation.in_suite_teardown("MySuite"),
                               expected=False)
    assert len(marker) == 1