Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e00bcc

Browse files
committed
Merge master with next-gen
2 parents 142bd4a + 4da1dea commit 5e00bcc

File tree

2 files changed

+34
-54
lines changed

2 files changed

+34
-54
lines changed

docs/changelog.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ Versions follow `Semantic Versioning`_ (``<major>.<minor>.<patch>``).
66
Version History
77
---------------
88

9-
3.2.0 (unreleased)
9+
3.2.0 (2022-10-25)
1010
~~~~~~~~~~~~~~~~~~
1111

12+
* Explicitly add py.xml dependency.
13+
14+
* Thanks to `@smartEBL <https://github.com/smartEBL>`_ for the PR
15+
1216
* 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>`_)
1317

1418
* Thanks to `@TheCorp <https://github.com/TheCorp>`_ for reporting and `@gnikonorov <https://github.com/gnikonorov>`_ for the fix

testing/legacy_test_pytest_html.py

Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,18 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
import builtins
54
import json
65
import os
76
import random
87
import re
8+
import sys
99
from base64 import b64encode
1010

1111
import pkg_resources
1212
import pytest
1313

1414
pytest_plugins = ("pytester",)
1515

16-
if os.name == "nt":
17-
# Force a utf-8 encoding on file io (since by default windows does not). See
18-
# https://github.com/pytest-dev/pytest-html/issues/336
19-
# If we drop support for Python 3.6 and earlier could use python -X utf8 instead.
20-
_real_open = builtins.open
21-
22-
def _open(file, mode="r", buffering=-1, encoding=None, *args, **kwargs):
23-
if mode in ("r", "w") and encoding is None:
24-
encoding = "utf-8"
25-
26-
return _real_open(file, mode, buffering, encoding, *args, **kwargs)
27-
28-
builtins.open = _open
29-
30-
31-
def remove_deprecation_from_recwarn(recwarn):
32-
# TODO: Temporary hack until they fix
33-
# https://github.com/pytest-dev/pytest/issues/6936
34-
return [
35-
item for item in recwarn if "TerminalReporter.writer" not in repr(item.message)
36-
]
37-
3816

3917
def run(testdir, path="report.html", *args):
4018
path = testdir.tmpdir.join(path)
@@ -186,7 +164,7 @@ def test_fail(self, testdir):
186164
assert_results(html, passed=0, failed=1)
187165
assert "AssertionError" in html
188166

189-
@pytest.mark.flaky(reruns=2) # test is flaky on windows
167+
@pytest.mark.skipif(sys.platform == "win32", reason="Test is flaky on Windows")
190168
def test_rerun(self, testdir):
191169
testdir.makeconftest(
192170
"""
@@ -972,12 +950,12 @@ def test_ansi():
972950
assert result.ret == 0
973951
assert not re.search(r"\[[\d;]+m", html)
974952

975-
@pytest.mark.parametrize("content", [("'foo'"), ("u'\u0081'")])
953+
@pytest.mark.parametrize("content", ["'foo'", "u'\u0081'"])
976954
def test_utf8_longrepr(self, testdir, content):
977955
testdir.makeconftest(
978956
f"""
979957
import pytest
980-
@pytest.hookimpl(hookwrapper=True)
958+
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
981959
def pytest_runtest_makereport(item, call):
982960
outcome = yield
983961
report = outcome.get_result()
@@ -1021,37 +999,35 @@ def test_css(self, testdir, recwarn, colors):
1021999
cssargs.extend(["--css", path])
10221000
result, html = run(testdir, "report.html", "--self-contained-html", *cssargs)
10231001
assert result.ret == 0
1024-
warnings = remove_deprecation_from_recwarn(recwarn)
1025-
assert len(warnings) == 0
10261002
for k, v in css.items():
10271003
assert str(v["path"]) in html
10281004
assert v["style"] in html
10291005

1030-
@pytest.mark.parametrize(
1031-
"files",
1032-
[
1033-
"style.css",
1034-
["abc.css", "xyz.css"],
1035-
"testdir.makefile('.css', * {color: 'white'}",
1036-
],
1037-
)
1038-
def test_css_invalid(self, testdir, recwarn, files):
1039-
testdir.makepyfile("def test_pass(): pass")
1040-
path = files
1041-
if isinstance(files, list):
1042-
file1 = files[0]
1043-
file2 = files[1]
1044-
result = testdir.runpytest(
1045-
"--html", "report.html", "--css", file1, "--css", file2
1046-
)
1047-
else:
1048-
result = testdir.runpytest("--html", "report.html", "--css", path)
1049-
assert result.ret
1050-
assert len(recwarn) == 0
1051-
if isinstance(files, list):
1052-
assert files[0] in result.stderr.str() and files[1] in result.stderr.str()
1053-
else:
1054-
assert path in result.stderr.str()
1006+
# @pytest.mark.parametrize(
1007+
# "files",
1008+
# [
1009+
# "style.css",
1010+
# ["abc.css", "xyz.css"],
1011+
# "testdir.makefile('.css', * {color: 'white'}",
1012+
# ],
1013+
# )
1014+
# def test_css_invalid(self, testdir, recwarn, files):
1015+
# testdir.makepyfile("def test_pass(): pass")
1016+
# path = files
1017+
# if isinstance(files, list):
1018+
# file1 = files[0]
1019+
# file2 = files[1]
1020+
# result = testdir.runpytest(
1021+
# "--html", "report.html", "--css", file1, "--css", file2
1022+
# )
1023+
# else:
1024+
# result = testdir.runpytest("--html", "report.html", "--css", path)
1025+
# assert result.ret
1026+
# assert len(recwarn) == 0
1027+
# if isinstance(files, list):
1028+
# assert files[0] in result.stderr.str() and files[1] in result.stderr.str()
1029+
# else:
1030+
# assert path in result.stderr.str()
10551031

10561032
def test_css_invalid_no_html(self, testdir):
10571033
testdir.makepyfile("def test_pass(): pass")

0 commit comments

Comments
 (0)