Merge master with next-gen
This commit is contained in:
commit
5e00bccbde
|
@ -6,9 +6,13 @@ Versions follow `Semantic Versioning`_ (``<major>.<minor>.<patch>``).
|
||||||
Version History
|
Version History
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
3.2.0 (unreleased)
|
3.2.0 (2022-10-25)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
* Explicitly add py.xml dependency.
|
||||||
|
|
||||||
|
* Thanks to `@smartEBL <https://github.com/smartEBL>`_ for the PR
|
||||||
|
|
||||||
* Implement the ``visible`` URL query parameter to control visibility of test results on page load. (`#399 <https://github.com/pytest-dev/pytest-html/issues/399>`_)
|
* Implement the ``visible`` URL query parameter to control visibility of test results on page load. (`#399 <https://github.com/pytest-dev/pytest-html/issues/399>`_)
|
||||||
|
|
||||||
* Thanks to `@TheCorp <https://github.com/TheCorp>`_ for reporting and `@gnikonorov <https://github.com/gnikonorov>`_ for the fix
|
* Thanks to `@TheCorp <https://github.com/TheCorp>`_ for reporting and `@gnikonorov <https://github.com/gnikonorov>`_ for the fix
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
import builtins
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
@ -13,28 +13,6 @@ import pytest
|
||||||
|
|
||||||
pytest_plugins = ("pytester",)
|
pytest_plugins = ("pytester",)
|
||||||
|
|
||||||
if os.name == "nt":
|
|
||||||
# Force a utf-8 encoding on file io (since by default windows does not). See
|
|
||||||
# https://github.com/pytest-dev/pytest-html/issues/336
|
|
||||||
# If we drop support for Python 3.6 and earlier could use python -X utf8 instead.
|
|
||||||
_real_open = builtins.open
|
|
||||||
|
|
||||||
def _open(file, mode="r", buffering=-1, encoding=None, *args, **kwargs):
|
|
||||||
if mode in ("r", "w") and encoding is None:
|
|
||||||
encoding = "utf-8"
|
|
||||||
|
|
||||||
return _real_open(file, mode, buffering, encoding, *args, **kwargs)
|
|
||||||
|
|
||||||
builtins.open = _open
|
|
||||||
|
|
||||||
|
|
||||||
def remove_deprecation_from_recwarn(recwarn):
|
|
||||||
# TODO: Temporary hack until they fix
|
|
||||||
# https://github.com/pytest-dev/pytest/issues/6936
|
|
||||||
return [
|
|
||||||
item for item in recwarn if "TerminalReporter.writer" not in repr(item.message)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def run(testdir, path="report.html", *args):
|
def run(testdir, path="report.html", *args):
|
||||||
path = testdir.tmpdir.join(path)
|
path = testdir.tmpdir.join(path)
|
||||||
|
@ -186,7 +164,7 @@ class TestHTML:
|
||||||
assert_results(html, passed=0, failed=1)
|
assert_results(html, passed=0, failed=1)
|
||||||
assert "AssertionError" in html
|
assert "AssertionError" in html
|
||||||
|
|
||||||
@pytest.mark.flaky(reruns=2) # test is flaky on windows
|
@pytest.mark.skipif(sys.platform == "win32", reason="Test is flaky on Windows")
|
||||||
def test_rerun(self, testdir):
|
def test_rerun(self, testdir):
|
||||||
testdir.makeconftest(
|
testdir.makeconftest(
|
||||||
"""
|
"""
|
||||||
|
@ -972,12 +950,12 @@ class TestHTML:
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
assert not re.search(r"\[[\d;]+m", html)
|
assert not re.search(r"\[[\d;]+m", html)
|
||||||
|
|
||||||
@pytest.mark.parametrize("content", [("'foo'"), ("u'\u0081'")])
|
@pytest.mark.parametrize("content", ["'foo'", "u'\u0081'"])
|
||||||
def test_utf8_longrepr(self, testdir, content):
|
def test_utf8_longrepr(self, testdir, content):
|
||||||
testdir.makeconftest(
|
testdir.makeconftest(
|
||||||
f"""
|
f"""
|
||||||
import pytest
|
import pytest
|
||||||
@pytest.hookimpl(hookwrapper=True)
|
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||||
def pytest_runtest_makereport(item, call):
|
def pytest_runtest_makereport(item, call):
|
||||||
outcome = yield
|
outcome = yield
|
||||||
report = outcome.get_result()
|
report = outcome.get_result()
|
||||||
|
@ -1021,37 +999,35 @@ class TestHTML:
|
||||||
cssargs.extend(["--css", path])
|
cssargs.extend(["--css", path])
|
||||||
result, html = run(testdir, "report.html", "--self-contained-html", *cssargs)
|
result, html = run(testdir, "report.html", "--self-contained-html", *cssargs)
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
warnings = remove_deprecation_from_recwarn(recwarn)
|
|
||||||
assert len(warnings) == 0
|
|
||||||
for k, v in css.items():
|
for k, v in css.items():
|
||||||
assert str(v["path"]) in html
|
assert str(v["path"]) in html
|
||||||
assert v["style"] in html
|
assert v["style"] in html
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
# @pytest.mark.parametrize(
|
||||||
"files",
|
# "files",
|
||||||
[
|
# [
|
||||||
"style.css",
|
# "style.css",
|
||||||
["abc.css", "xyz.css"],
|
# ["abc.css", "xyz.css"],
|
||||||
"testdir.makefile('.css', * {color: 'white'}",
|
# "testdir.makefile('.css', * {color: 'white'}",
|
||||||
],
|
# ],
|
||||||
)
|
# )
|
||||||
def test_css_invalid(self, testdir, recwarn, files):
|
# def test_css_invalid(self, testdir, recwarn, files):
|
||||||
testdir.makepyfile("def test_pass(): pass")
|
# testdir.makepyfile("def test_pass(): pass")
|
||||||
path = files
|
# path = files
|
||||||
if isinstance(files, list):
|
# if isinstance(files, list):
|
||||||
file1 = files[0]
|
# file1 = files[0]
|
||||||
file2 = files[1]
|
# file2 = files[1]
|
||||||
result = testdir.runpytest(
|
# result = testdir.runpytest(
|
||||||
"--html", "report.html", "--css", file1, "--css", file2
|
# "--html", "report.html", "--css", file1, "--css", file2
|
||||||
)
|
# )
|
||||||
else:
|
# else:
|
||||||
result = testdir.runpytest("--html", "report.html", "--css", path)
|
# result = testdir.runpytest("--html", "report.html", "--css", path)
|
||||||
assert result.ret
|
# assert result.ret
|
||||||
assert len(recwarn) == 0
|
# assert len(recwarn) == 0
|
||||||
if isinstance(files, list):
|
# if isinstance(files, list):
|
||||||
assert files[0] in result.stderr.str() and files[1] in result.stderr.str()
|
# assert files[0] in result.stderr.str() and files[1] in result.stderr.str()
|
||||||
else:
|
# else:
|
||||||
assert path in result.stderr.str()
|
# assert path in result.stderr.str()
|
||||||
|
|
||||||
def test_css_invalid_no_html(self, testdir):
|
def test_css_invalid_no_html(self, testdir):
|
||||||
testdir.makepyfile("def test_pass(): pass")
|
testdir.makepyfile("def test_pass(): pass")
|
||||||
|
|
Loading…
Reference in New Issue