Ejemplo n.º 1
0
def test_session_prerun_fixture_user_error():
    @lcc.fixture(scope="session_prerun")
    def fix():
        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_skipped(report)
Ejemplo n.º 2
0
def test_session_prerun_fixture_exception():
    @lcc.fixture(scope="session_prerun")
    def fix():
        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_skipped(report)
Ejemplo n.º 3
0
def test_setup_suite_error_because_of_error_log():
    marker = []

    @lcc.suite("MySuite")
    class MySuite:
        def setup_suite(self):
            lcc.log_error("some error")

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

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

    report = run_suite_class(MySuite)

    assert_test_skipped(report)
    assert not marker
Ejemplo n.º 4
0
def test_setup_test_session_error_and_setup_suite():
    marker = []

    @lcc.suite("MySuite")
    class MySuite:
        def setup_suite(self, fixt):
            marker.append("setup_suite")

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

    @lcc.fixture(scope="session")
    def fixt():
        1 / 0

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

    assert_test_skipped(report)
    assert_report_node_success(report,
                               TreeLocation.in_test_session_setup(),
                               expected=False)
    assert not marker