Skip to content

Commit ea89db8

Browse files
authored
fix: upgrade pip before running tox (#522)
* fix: upgrade pip before running tox * Use "-X utf8" to solve encoding issues on Windows * Disable pypy3.8 on windows
1 parent 3fbfd25 commit ea89db8

File tree

3 files changed

+19
-33
lines changed

3 files changed

+19
-33
lines changed

.github/workflows/tests.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ jobs:
6363
name: pypy3-ubuntu
6464
python-version: pypy-3.8
6565

66-
- os: windows-latest
67-
name: pypy3-windows
68-
python-version: pypy-3.8
66+
# TODO: This test takes 10(!) times as long as the regular py38 on Windows
67+
# - os: windows-latest
68+
# name: pypy3-windows
69+
# python-version: pypy-3.8
6970

7071
# https://github.com/pytest-dev/pytest-html/issues/482
7172
- os: macOS-latest
@@ -79,27 +80,37 @@ jobs:
7980
steps:
8081
- name: Set Newline Behavior
8182
run : git config --global core.autocrlf false
83+
8284
- uses: actions/checkout@v3
8385
with:
8486
fetch-depth: 0
87+
8588
- name: Set up Python
8689
uses: actions/setup-python@v3
8790
with:
8891
python-version: ${{ matrix['python-version'] }}
92+
93+
- name: Upgrade pip
94+
run: python -m pip install --upgrade pip
95+
8996
- name: Install tox
9097
run: python -m pip install --upgrade tox
98+
9199
- name: Get Tox Environment Name From Matrix Name
92100
uses: rishabhgupta/split-by@v1
93101
id: split-matrix-name
94102
with:
95103
string: '${{ matrix.name }}'
96104
split-by: '-'
105+
97106
- name: Test with coverage
98107
if: "! contains(matrix.name, 'pypy3')"
99-
run: python -m tox -e ${{ steps.split-matrix-name.outputs._0}}-cov
108+
run: python -m tox -rvv -e ${{ steps.split-matrix-name.outputs._0}}-cov
109+
100110
- name: Test without coverage
101111
if: "contains(matrix.name, 'pypy3')"
102112
run: python -m tox -e ${{ steps.split-matrix-name.outputs._0}}
113+
103114
# TODO: https://github.com/pytest-dev/pytest-html/issues/481
104115
# - name: Upload coverage to codecov
105116
# if: github.event.schedule == ''

testing/test_pytest_html.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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
@@ -13,28 +12,6 @@
1312

1413
pytest_plugins = ("pytester",)
1514

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-
3815

3916
def run(testdir, path="report.html", *args):
4017
path = testdir.tmpdir.join(path)
@@ -972,12 +949,12 @@ def test_ansi():
972949
assert result.ret == 0
973950
assert not re.search(r"\[[\d;]+m", html)
974951

975-
@pytest.mark.parametrize("content", [("'foo'"), ("u'\u0081'")])
952+
@pytest.mark.parametrize("content", ["'foo'", "u'\u0081'"])
976953
def test_utf8_longrepr(self, testdir, content):
977954
testdir.makeconftest(
978955
f"""
979956
import pytest
980-
@pytest.hookimpl(hookwrapper=True)
957+
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
981958
def pytest_runtest_makereport(item, call):
982959
outcome = yield
983960
report = outcome.get_result()
@@ -1021,8 +998,6 @@ def test_css(self, testdir, recwarn, colors):
1021998
cssargs.extend(["--css", path])
1022999
result, html = run(testdir, "report.html", "--self-contained-html", *cssargs)
10231000
assert result.ret == 0
1024-
warnings = remove_deprecation_from_recwarn(recwarn)
1025-
assert len(warnings) == 0
10261001
for k, v in css.items():
10271002
assert str(v["path"]) in html
10281003
assert v["style"] in html

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ deps =
1616
ansi2html # soft-dependency
1717
cov: pytest-cov
1818
commands =
19-
!cov: pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs}
20-
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}
19+
!cov: python -X utf8 -m pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs}
20+
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}
2121

2222
[testenv:linting]
2323
skip_install = True

0 commit comments

Comments
 (0)