From 983730c99f5f52f18994c06bb4ef4c12ebdc41a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Br=C3=A4nnlund?= Date: Sun, 3 Jul 2022 13:31:16 +0200 Subject: [PATCH 1/4] fix: upgrade pip before running tox --- .github/workflows/tests.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 84be7269..68542d27 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -79,27 +79,37 @@ jobs: steps: - name: Set Newline Behavior run : git config --global core.autocrlf false + - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up Python uses: actions/setup-python@v3 with: python-version: ${{ matrix['python-version'] }} + + - name: Upgrade pip + run: python -m pip install --upgrade pip + - name: Install tox run: python -m pip install --upgrade tox + - name: Get Tox Environment Name From Matrix Name uses: rishabhgupta/split-by@v1 id: split-matrix-name with: string: '${{ matrix.name }}' split-by: '-' + - name: Test with coverage if: "! contains(matrix.name, 'pypy3')" - run: python -m tox -e ${{ steps.split-matrix-name.outputs._0}}-cov + run: python -m tox -rvv -e ${{ steps.split-matrix-name.outputs._0}}-cov + - name: Test without coverage if: "contains(matrix.name, 'pypy3')" run: python -m tox -e ${{ steps.split-matrix-name.outputs._0}} + # TODO: https://github.com/pytest-dev/pytest-html/issues/481 # - name: Upload coverage to codecov # if: github.event.schedule == '' From c5b9cab47af604be194cf9a02c993f9057c50941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Br=C3=A4nnlund?= Date: Sat, 16 Jul 2022 00:49:23 +0200 Subject: [PATCH 2/4] Use "-X utf8" to solve encoding issues on Windows --- testing/test_pytest_html.py | 32 ++++++++++++++++---------------- tox.ini | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/testing/test_pytest_html.py b/testing/test_pytest_html.py index b13dd4c6..4cba4b0e 100644 --- a/testing/test_pytest_html.py +++ b/testing/test_pytest_html.py @@ -1,7 +1,7 @@ # 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 # file, You can obtain one at http://mozilla.org/MPL/2.0/. -import builtins +#import builtins import json import os import random @@ -13,19 +13,19 @@ 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 +# 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): @@ -972,12 +972,12 @@ def test_ansi(): assert result.ret == 0 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): testdir.makeconftest( f""" import pytest - @pytest.hookimpl(hookwrapper=True) + @pytest.hookimpl(tryfirst=True, hookwrapper=True) def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() diff --git a/tox.ini b/tox.ini index 0d9b6480..9b279358 100644 --- a/tox.ini +++ b/tox.ini @@ -16,8 +16,8 @@ deps = ansi2html # soft-dependency cov: pytest-cov commands = - !cov: pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs} - cov: pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html --cov={envsitepackagesdir}/pytest_html --cov-report=term --cov-report=xml {posargs} + !cov: python -X utf8 -m pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs} + cov: python -X utf8 -m pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html --cov={envsitepackagesdir}/pytest_html --cov-report=term --cov-report=xml {posargs} [testenv:linting] skip_install = True From 11a368dbfa212dda1d373f2825e7144b8dc2e3b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Jul 2022 22:49:37 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/test_pytest_html.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/testing/test_pytest_html.py b/testing/test_pytest_html.py index 4cba4b0e..091e3f3c 100644 --- a/testing/test_pytest_html.py +++ b/testing/test_pytest_html.py @@ -1,7 +1,7 @@ # 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 # file, You can obtain one at http://mozilla.org/MPL/2.0/. -#import builtins +# import builtins import json import os import random @@ -28,12 +28,12 @@ # 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 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): @@ -1021,8 +1021,8 @@ def test_css(self, testdir, recwarn, colors): cssargs.extend(["--css", path]) result, html = run(testdir, "report.html", "--self-contained-html", *cssargs) assert result.ret == 0 - warnings = remove_deprecation_from_recwarn(recwarn) - assert len(warnings) == 0 + # warnings = remove_deprecation_from_recwarn(recwarn) + # assert len(warnings) == 0 for k, v in css.items(): assert str(v["path"]) in html assert v["style"] in html From 1fbb624dcb853e7ce9ea23ffaa48284ae29a342e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Br=C3=A4nnlund?= Date: Sat, 16 Jul 2022 01:09:26 +0200 Subject: [PATCH 4/4] Disable pypy3.8 on windows --- .github/workflows/tests.yml | 7 ++++--- testing/test_pytest_html.py | 25 ------------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 68542d27..c914d2fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,9 +63,10 @@ jobs: name: pypy3-ubuntu python-version: pypy-3.8 - - os: windows-latest - name: pypy3-windows - python-version: pypy-3.8 + # TODO: This test takes 10(!) times as long as the regular py38 on Windows +# - os: windows-latest +# name: pypy3-windows +# python-version: pypy-3.8 # https://github.com/pytest-dev/pytest-html/issues/482 - os: macOS-latest diff --git a/testing/test_pytest_html.py b/testing/test_pytest_html.py index 091e3f3c..88477556 100644 --- a/testing/test_pytest_html.py +++ b/testing/test_pytest_html.py @@ -1,7 +1,6 @@ # 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 # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# import builtins import json import os import random @@ -13,28 +12,6 @@ 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): path = testdir.tmpdir.join(path) @@ -1021,8 +998,6 @@ def test_css(self, testdir, recwarn, colors): cssargs.extend(["--css", path]) result, html = run(testdir, "report.html", "--self-contained-html", *cssargs) assert result.ret == 0 - # warnings = remove_deprecation_from_recwarn(recwarn) - # assert len(warnings) == 0 for k, v in css.items(): assert str(v["path"]) in html assert v["style"] in html