def test_pytest_failed_finalizer_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def pytest_failed_finalizer_fixture(request):
    ...     def fixture_finalizer():
    ...         pytest.fail()
    ...     request.addfinalizer(fixture_finalizer)

    >>> def test_pytest_failed_finalizer_fixture_example(pytest_failed_finalizer_fixture):
    ...     pass
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_pytest_failed_finalizer_fixture_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("Failed: <Failed instance>"),
                                                 with_trace_contains("def fixture_finalizer():")
                                                 ),
                              has_container(executed_docstring_source.allure_report,
                                            has_after("{fixture}::{finalizer}".format(
                                                fixture="pytest_failed_finalizer_fixture",
                                                finalizer="fixture_finalizer"),
                                                with_status("failed"),
                                                has_status_details(with_message_contains("Failed: <Failed instance>"),
                                                                   with_trace_contains("fixture_finalizer")
                                                                   ),
                                            ),
                                            )
                              )
                )
def test_xfail_failed_finalizer_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def failed_finalizer_fixture(request):
    ...     def fixture_finalizer():
    ...         assert False
    ...     request.addfinalizer(fixture_finalizer)

    >>> @pytest.mark.xfail()
    ... def test_xfail_failed_finalizer_fixture_example(failed_finalizer_fixture):
    ...     pass
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_xfail_failed_finalizer_fixture_example",
                              with_status("passed"),
                              has_status_details(with_message_contains("XPASS")),
                              has_container(executed_docstring_source.allure_report,
                                            has_after("{fixture}::{finalizer}".format(
                                                fixture="failed_finalizer_fixture",
                                                finalizer="fixture_finalizer"),
                                                with_status("failed"),
                                                has_status_details(with_message_contains("AssertionError"),
                                                                   with_trace_contains("fixture_finalizer")
                                                                   ),
                                            ),
                                            )
                              )
                )
Exemplo n.º 3
0
def test_pytest_fail_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def pytest_fail_fixture():
    ...     pytest.fail()

    >>> def test_pytest_fail_fixture_example(pytest_fail_fixture):
    ...     pass
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_pytest_fail_fixture_example", with_status("failed"),
            has_status_details(
                with_message_contains("Failed: <Failed instance>"),
                with_trace_contains("def pytest_fail_fixture():")),
            has_container(
                executed_docstring_source.allure_report,
                has_before(
                    "pytest_fail_fixture",
                    with_status("failed"),
                    has_status_details(
                        with_message_contains("Failed: <Failed instance>"),
                        with_trace_contains("pytest_fail_fixture")),
                ),
            )))
Exemplo n.º 4
0
def test_failed_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def failed_fixture():
    ...     assert False

    >>> def test_failed_fixture_example(failed_fixture):
    ...     pass
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_failed_fixture_example", with_status("failed"),
            has_status_details(with_message_contains("AssertionError"),
                               with_trace_contains("def failed_fixture():")),
            has_container(
                executed_docstring_source.allure_report,
                has_before(
                    "failed_fixture",
                    with_status("failed"),
                    has_status_details(with_message_contains("AssertionError"),
                                       with_trace_contains("failed_fixture")),
                ),
            )))
Exemplo n.º 5
0
def test_pytest_failed_finalizer_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def pytest_failed_finalizer_fixture(request):
    ...     def fixture_finalizer():
    ...         pytest.fail()
    ...     request.addfinalizer(fixture_finalizer)

    >>> def test_pytest_failed_finalizer_fixture_example(pytest_failed_finalizer_fixture):
    ...     pass
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_pytest_failed_finalizer_fixture_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("Failed"),
                                                 with_trace_contains("def fixture_finalizer():")
                                                 ),
                              has_container(executed_docstring_source.allure_report,
                                            has_after("{fixture}::{finalizer}".format(
                                                fixture="pytest_failed_finalizer_fixture",
                                                finalizer="fixture_finalizer"),
                                                with_status("failed"),
                                                has_status_details(with_message_contains("Failed"),
                                                                   with_trace_contains("fixture_finalizer")
                                                                   ),
                                            ),
                                            )
                              )
                )
def test_pytest_bytes_data_in_assert(executed_docstring_source):
    """
    >>> import allure

    >>> def test_pytest_bytes_data_in_assert_example():
    ...     with allure.step("Step"):
    ...         assert "0\\x82" == 1
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_pytest_bytes_data_in_assert_example", with_status("failed"),
            has_status_details(
                with_message_contains(
                    "AssertionError: assert \'0\\x82\' == 1"),
                with_trace_contains(
                    "def test_pytest_bytes_data_in_assert_example():")),
            has_step(
                "Step", with_status("failed"),
                has_status_details(
                    with_message_contains(
                        "AssertionError: assert \'0\\x82\' == 1"),
                    with_trace_contains(
                        "test_pytest_bytes_data_in_assert_example")))))
Exemplo n.º 7
0
def test_skip_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def skip_fixture():
    ...     pytest.skip()

    >>> @pytest.mark.xfail()
    ... def test_skip_fixture_example(skip_fixture):
    ...     pass
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_skip_fixture_example", with_status("skipped"),
            has_status_details(
                with_message_contains("Skipped: <Skipped instance>")),
            has_container(
                executed_docstring_source.allure_report,
                has_before(
                    "skip_fixture",
                    with_status("skipped"),
                    has_status_details(
                        with_message_contains("Skipped: <Skipped instance>"),
                        with_trace_contains("skip_fixture")),
                ),
            )))
def test_xfail_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def broken_fixture():
    ...     raise NotImplementedError

    >>> @pytest.mark.xfail()
    ... def test_xfail_fixture_example(broken_fixture):
    ...     pass
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_xfail_fixture_example", with_status("skipped"),
            has_status_details(with_message_contains("NotImplementedError"),
                               with_trace_contains("def broken_fixture():")),
            has_container(
                executed_docstring_source.allure_report,
                has_before(
                    "broken_fixture",
                    with_status("broken"),
                    has_status_details(
                        with_message_contains("NotImplementedError"),
                        with_trace_contains("broken_fixture")),
                ),
            )))
def test_failed_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def failed_fixture():
    ...     assert False

    >>> def test_failed_fixture_example(failed_fixture):
    ...     pass
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_failed_fixture_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("AssertionError"),
                                                 with_trace_contains("def failed_fixture():")
                                                 ),
                              has_container(executed_docstring_source.allure_report,
                                            has_before("failed_fixture",
                                                       with_status("failed"),
                                                       has_status_details(with_message_contains("AssertionError"),
                                                                          with_trace_contains("failed_fixture")
                                                                          ),
                                                       ),
                                            )
                              )
                )
def test_broken_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def broken_fixture():
    ...     raise IndexError

    >>> def test_broken_fixture_example(broken_fixture):
    ...     pass
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_broken_fixture_example",
                              with_status("broken"),
                              has_status_details(with_message_contains("IndexError"),
                                                 with_trace_contains("def broken_fixture():")
                                                 ),
                              has_container(executed_docstring_source.allure_report,
                                            has_before("broken_fixture",
                                                       with_status("broken"),
                                                       has_status_details(with_message_contains("IndexError"),
                                                                          with_trace_contains("broken_fixture")
                                                                          ),
                                                       ),
                                            )
                              )
                )
def test_pytest_fail_fixture(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.fixture
    ... def pytest_fail_fixture():
    ...     pytest.fail()

    >>> def test_pytest_fail_fixture_example(pytest_fail_fixture):
    ...     pass
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_pytest_fail_fixture_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("Failed: <Failed instance>"),
                                                 with_trace_contains("def pytest_fail_fixture():")
                                                 ),
                              has_container(executed_docstring_source.allure_report,
                                            has_before("pytest_fail_fixture",
                                                       with_status("failed"),
                                                       has_status_details(
                                                           with_message_contains("Failed: <Failed instance>"),
                                                           with_trace_contains("pytest_fail_fixture")
                                                       ),
                                                       ),
                                            )
                              )
                )
Exemplo n.º 12
0
def test_xfail_step_failure(executed_docstring_source):
    """
    >>> import pytest
    >>> import allure

    >>> @pytest.mark.xfail()
    ... def test_xfail_step_failure_example():
    ...     with allure.step("Step"):
    ...         assert False
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_xfail_step_failure_example",
                              with_status("skipped"),
                              has_status_details(with_message_contains("AssertionError"),
                                                 with_trace_contains("def test_xfail_step_failure_example():")
                                                 ),
                              has_step("Step",
                                       with_status("failed"),
                                       has_status_details(with_message_contains("AssertionError"),
                                                          with_trace_contains("test_xfail_step_failure_example")
                                                          )
                                       )
                              )
                )
Exemplo n.º 13
0
 def test_failed_with_details(self):
     assert_that(self.allure_report, has_test_case('Failed Case With Message',
                                                   with_status('failed'),
                                                   has_status_details(with_message_contains('Failed Details')
                                                                      )
                                                   )
                 )
def test_pytest_check(allured_testdir):
    """
    >>> import pytest_check as check
    >>> def test_pytest_check_example():
    ...     check.equal(1, 2, msg="First failure")
    ...     check.equal(1, 2, msg="Second failure")
    """

    allured_testdir.parse_docstring_source()
    allured_testdir.run_with_allure()

    assert_that(
        allured_testdir.allure_report,
        has_test_case(
            "test_pytest_check_example", with_status("failed"),
            has_status_details(with_message_contains("First failure"),
                               with_message_contains("Second failure"))),
    )
Exemplo n.º 15
0
def test_xfail_with_reason_raise_mentioned_exception(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.mark.xfail(raises=AssertionError, reason='Some reason')
    ... def test_xfail_with_reason_raise_mentioned_exception_example():
    ...     assert False

    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_xfail_with_reason_raise_mentioned_exception_example",
                              with_status("skipped"),
                              has_status_details(with_message_contains("XFAIL Some reason"),
                                                 with_message_contains("AssertionError"),
                                                 with_trace_contains(
                                                     "def test_xfail_with_reason_raise_mentioned_exception_example():")
                                                 )
                              )
                )
def test_broken_step(executed_docstring_source):
    """
    >>> import allure

    >>> def test_broken_step_example():
    ...     with allure.step("Step"):
    ...         raise ZeroDivisionError
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_broken_step_example", with_status("broken"),
            has_status_details(
                with_message_contains("ZeroDivisionError"),
                with_trace_contains("def test_broken_step_example():")),
            has_step(
                "Step", with_status("broken"),
                has_status_details(
                    with_message_contains("ZeroDivisionError"),
                    with_trace_contains("test_broken_step_example")))))
def test_skip_in_step(executed_docstring_source):
    """
    >>> import pytest
    >>> import allure

    >>> def test_skip_in_step_example():
    ...     with allure.step("Step"):
    ...         pytest.skip()
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_skip_in_step_example", with_status("skipped"),
            has_status_details(
                with_message_contains("Skipped: <Skipped instance>")),
            has_step(
                "Step", with_status("skipped"),
                has_status_details(
                    with_message_contains("Skipped: <Skipped instance>"),
                    with_trace_contains("test_skip_in_step")))))
def test_skip(executed_docstring_source):
    """
    >>> import pytest

    >>> def test_skip_example():
    ...     pytest.skip()
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case("test_skip_example", with_status("skipped"),
                      has_status_details(with_message_contains("Skipped"))))
Exemplo n.º 19
0
def test_broken(executed_docstring_source):
    """
    >>> def test_broken_example():
    ...     raise IndentationError()
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_broken_example", with_status("broken"),
            has_status_details(
                with_message_contains("IndentationError"),
                with_trace_contains("def test_broken_example():"))))
Exemplo n.º 20
0
def test_failed(executed_docstring_source):
    """
    >>> def test_failed_example():
    ...     assert False
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_failed_example", with_status("failed"),
            has_status_details(
                with_message_contains("AssertionError"),
                with_trace_contains("def test_failed_example():"))))
def test_pytest_fail_in_step(executed_docstring_source):
    """
    >>> import pytest
    >>> import allure

    >>> def test_pytest_fail_in_step_example():
    ...     with allure.step("Step"):
    ...         pytest.fail()
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_pytest_fail_in_step_example", with_status("failed"),
            has_status_details(
                with_message_contains("Failed"),
                with_trace_contains(
                    "def test_pytest_fail_in_step_example():")),
            has_step(
                "Step", with_status("failed"),
                has_status_details(
                    with_message_contains("Failed"),
                    with_trace_contains("test_pytest_fail_in_step_example")))))
def test_xfail_do_not_raise_mentioned_exception(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.mark.xfail(raises=AssertionError)
    ... def test_xfail_do_not_raise_mentioned_exception_example():
    ...     pass
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case("test_xfail_do_not_raise_mentioned_exception_example",
                      with_status("passed"),
                      has_status_details(with_message_contains("XPASS"), )))
Exemplo n.º 23
0
    def test_skipped_status(self):
        """
        >>> import unittest

        >>> class TestStatusExample(unittest.TestCase):
        ...     def test_skipped_example(self):
        ...         self.skipTest('my skip reason')
        """
        allure_report = run_docstring_example()
        assert_that(
            allure_report,
            has_test_case(
                "test_skipped_example", with_status("skipped"),
                has_status_details(with_message_contains("my skip reason"))))
def test_skipif_true(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.mark.skipif(True, reason="Skip reason")
    ... def test_skipif_true_example():
    ...     pass
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_skipif_true_example", with_status("skipped"),
            has_status_details(with_message_contains("Skipped: Skip reason"))))
Exemplo n.º 25
0
    def test_broken_status(self):
        """
        >>> import unittest

        >>> class TestStatusExample(unittest.TestCase):
        ...     def test_broken_example(self):
        ...         raise Exception("my error")
        """
        allure_report = run_docstring_example()
        assert_that(
            allure_report,
            has_test_case(
                "test_broken_example", with_status("broken"),
                has_status_details(with_message_contains("my error"))))
def test_broken(executed_docstring_source):
    """
    >>> def test_broken_example():
    ...     raise IndentationError()
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_broken_example",
                              with_status("broken"),
                              has_status_details(with_message_contains("IndentationError"),
                                                 with_trace_contains("def test_broken_example():")
                                                 )
                              )
                )
def test_failed(executed_docstring_source):
    """
    >>> def test_failed_example():
    ...     assert False
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_failed_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("AssertionError"),
                                                 with_trace_contains("def test_failed_example():")
                                                 )
                              )
                )
def test_broken_step(executed_docstring_source):
    """
    >>> import allure

    >>> def test_broken_step_example():
    ...     with allure.step("Step"):
    ...         raise ZeroDivisionError
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_broken_step_example",
                              with_status("broken"),
                              has_status_details(with_message_contains("ZeroDivisionError"),
                                                 with_trace_contains("def test_broken_step_example():")
                                                 ),
                              has_step("Step",
                                       with_status("broken"),
                                       has_status_details(with_message_contains("ZeroDivisionError"),
                                                          with_trace_contains("test_broken_step_example")
                                                          )
                                       )
                              )
                )
Exemplo n.º 29
0
    def test_failed_status(self):
        """
        >>> import unittest

        >>> class TestStatusExample(unittest.TestCase):
        ...     def test_failed_example(self):
        ...         assert False, "my message"
        """
        allure_report = run_docstring_example()
        assert_that(
            allure_report,
            has_test_case(
                "test_failed_example", with_status("failed"),
                has_status_details(with_message_contains("my message"))))
Exemplo n.º 30
0
def test_call_pytest_fail(executed_docstring_source):
    """
    >>> import pytest

    >>> def test_call_pytest_fail_example():
    ...     pytest.fail()
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_call_pytest_fail_example", with_status("failed"),
            has_status_details(
                with_message_contains("Failed: <Failed instance>"),
                with_trace_contains("def test_call_pytest_fail_example():"))))
def test_pytest_fail_in_step(executed_docstring_source):
    """
    >>> import pytest
    >>> import allure

    >>> def test_pytest_fail_in_step_example():
    ...     with allure.step("Step"):
    ...         pytest.fail()
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_pytest_fail_in_step_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("Failed: <Failed instance>"),
                                                 with_trace_contains("def test_pytest_fail_in_step_example():")
                                                 ),
                              has_step("Step",
                                       with_status("failed"),
                                       has_status_details(with_message_contains("Failed: <Failed instance>"),
                                                          with_trace_contains("test_pytest_fail_in_step_example")
                                                          )
                                       )
                              )
                )
def test_pytest_bytes_data_in_assert(executed_docstring_source):
    """
    >>> import allure

    >>> def test_pytest_bytes_data_in_assert_example():
    ...     with allure.step("Step"):
    ...         assert "0\\x82" == 1
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_pytest_bytes_data_in_assert_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("AssertionError: assert \'0\\x82\' == 1"),
                                                 with_trace_contains("def test_pytest_bytes_data_in_assert_example():")
                                                 ),
                              has_step("Step",
                                       with_status("failed"),
                                       has_status_details(
                                           with_message_contains("AssertionError: assert \'0\\x82\' == 1"),
                                           with_trace_contains("test_pytest_bytes_data_in_assert_example")
                                       )
                                       )
                              )
                )
def test_xfail_with_reason_do_not_raise_mentioned_exception(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.mark.xfail(raises=AssertionError, reason="Some reason")
    ... def test_xfail_with_reason_do_not_raise_mentioned_exception_example():
    ...     pass
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_xfail_with_reason_do_not_raise_mentioned_exception_example",
                              with_status("passed"),
                              has_status_details(with_message_contains("XPASS Some reason"),
                                                 )
                              )
                )
def test_xfail_with_run_false_and_with_reason(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.mark.xfail(run=False, reason="Some reason")
    ... def test_xfail_with_run_false_and_with_reason_example():
    ...     pass
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_xfail_with_run_false_and_with_reason_example",
            with_status("skipped"),
            has_status_details(
                with_message_contains("Failed: [NOTRUN] Some reason"))))
def test_call_pytest_fail_with_reason(executed_docstring_source):
    """
    >>> import pytest

    >>> def test_call_pytest_fail_with_reason_example():
    ...     pytest.fail("Fail message")
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_call_pytest_fail_with_reason_example",
                              with_status("failed"),
                              has_status_details(with_message_contains("Fail message"),
                                                 with_trace_contains("def test_call_pytest_fail_with_reason_example():")
                                                 )
                              )

                )
def test_args_less_than_placeholders(executed_docstring_source):
    """
    >>> import allure

    >>> @allure.step("{0} and {1}")
    ... def step(arg):
    ...     pass

    >>> def test_args_less_than_placeholders_example():
    ...     step(0)
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_args_less_than_placeholders_example",
                              has_status_details(with_message_contains("IndexError: tuple index out of range"))
                              )
                )
Exemplo n.º 37
0
def test_xfail_raise_not_mentioned_exception(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.mark.xfail(raises=AssertionError)
    ... def test_xfail_raise_not_mentioned_exception_example():
    ...     raise ZeroDivisionError
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_xfail_raise_not_mentioned_exception_example",
                              with_status("broken"),
                              has_status_details(with_message_contains("ZeroDivisionError"),
                                                 with_trace_contains(
                                                     "def test_xfail_raise_not_mentioned_exception_example():")
                                                 )
                              )
                )
def test_xfail_raise_not_mentioned_exception(executed_docstring_source):
    """
    >>> import pytest

    >>> @pytest.mark.xfail(raises=AssertionError)
    ... def test_xfail_raise_not_mentioned_exception_example():
    ...     raise ZeroDivisionError
    """

    assert_that(executed_docstring_source.allure_report,
                has_test_case("test_xfail_raise_not_mentioned_exception_example",
                              with_status("broken"),
                              has_status_details(with_message_contains("ZeroDivisionError"),
                                                 with_trace_contains(
                                                     "def test_xfail_raise_not_mentioned_exception_example():")
                                                 )
                              )
                )
Exemplo n.º 39
0
def test_args_less_than_placeholders(executed_docstring_source):
    """
    >>> import allure

    >>> @allure.step("{0} and {1}")
    ... def step(arg):
    ...     pass

    >>> def test_args_less_than_placeholders_example():
    ...     step(0)
    """

    assert_that(
        executed_docstring_source.allure_report,
        has_test_case(
            "test_args_less_than_placeholders_example",
            has_status_details(
                with_message_contains(
                    "IndexError: tuple index out of range"))))