diff --git a/pytest_reporter_html1/templates/html1/test.html b/pytest_reporter_html1/templates/html1/test.html index 4e8884b..a9de263 100644 --- a/pytest_reporter_html1/templates/html1/test.html +++ b/pytest_reporter_html1/templates/html1/test.html @@ -1,5 +1,5 @@ {% block test_content scoped %} -{% if test.item.function.__doc__ %} +{% if test.item.function and test.item.function.__doc__ %}
{{ test.item.function.__doc__|cleandoc|rst|safe }}
diff --git a/tests/samples/sample_doctest.txt b/tests/samples/sample_doctest.txt new file mode 100644 index 0000000..b99fc43 --- /dev/null +++ b/tests/samples/sample_doctest.txt @@ -0,0 +1,4 @@ +hello this is a doctest +>>> x = 3 +>>> x +4 diff --git a/tests/test_samples.py b/tests/test_samples.py index f0bc6f5..41f40e6 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -31,6 +31,7 @@ def test_sample_report(args, testdir, pytestconfig): report = "{}/report/{}".format(pytestconfig.rootdir, args[0]) result = testdir.runpytest( *args[1:], + "--doctest-glob", "sample_*.txt", "--template=html1/index.html", "--report=" + report )