|
1 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
2 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | | -import builtins |
5 | 4 | import json |
6 | 5 | import os |
7 | 6 | import random |
|
13 | 12 |
|
14 | 13 | pytest_plugins = ("pytester",) |
15 | 14 |
|
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 | | - |
38 | 15 |
|
39 | 16 | def run(testdir, path="report.html", *args): |
40 | 17 | path = testdir.tmpdir.join(path) |
@@ -972,12 +949,12 @@ def test_ansi(): |
972 | 949 | assert result.ret == 0 |
973 | 950 | assert not re.search(r"\[[\d;]+m", html) |
974 | 951 |
|
975 | | - @pytest.mark.parametrize("content", [("'foo'"), ("u'\u0081'")]) |
| 952 | + @pytest.mark.parametrize("content", ["'foo'", "u'\u0081'"]) |
976 | 953 | def test_utf8_longrepr(self, testdir, content): |
977 | 954 | testdir.makeconftest( |
978 | 955 | f""" |
979 | 956 | import pytest |
980 | | - @pytest.hookimpl(hookwrapper=True) |
| 957 | + @pytest.hookimpl(tryfirst=True, hookwrapper=True) |
981 | 958 | def pytest_runtest_makereport(item, call): |
982 | 959 | outcome = yield |
983 | 960 | report = outcome.get_result() |
@@ -1021,8 +998,6 @@ def test_css(self, testdir, recwarn, colors): |
1021 | 998 | cssargs.extend(["--css", path]) |
1022 | 999 | result, html = run(testdir, "report.html", "--self-contained-html", *cssargs) |
1023 | 1000 | assert result.ret == 0 |
1024 | | - warnings = remove_deprecation_from_recwarn(recwarn) |
1025 | | - assert len(warnings) == 0 |
1026 | 1001 | for k, v in css.items(): |
1027 | 1002 | assert str(v["path"]) in html |
1028 | 1003 | assert v["style"] in html |
|
0 commit comments