Skip to content

Commit b9bb5a9

Browse files
csm10495gnikonorov
andauthored
Enable testing on Windows and MacOS (#357)
Co-authored-by: Gleb Nikonorov <[email protected]>
1 parent b609a1d commit b9bb5a9

File tree

2 files changed

+89
-10
lines changed

2 files changed

+89
-10
lines changed

.github/workflows/actions.yml

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,83 @@ on:
1616
jobs:
1717
build_python:
1818
name: ${{ matrix.name }}
19-
runs-on: ubuntu-18.04
19+
runs-on: ${{ matrix.os }}
2020
strategy:
2121
matrix:
2222
include:
23-
- name: linting
23+
- os: ubuntu-18.04
24+
name: linting-ubuntu
25+
python-version: 3.6
26+
27+
- os: ubuntu-18.04
28+
name: py36-ubuntu
29+
python-version: 3.6
30+
31+
- os: windows-latest
32+
name: py36-windows
2433
python-version: 3.6
25-
- name: py36
34+
35+
- os: macOS-latest
36+
name: py36-mac
2637
python-version: 3.6
27-
- name: py37
38+
39+
- os: ubuntu-18.04
40+
name: py37-ubuntu
2841
python-version: 3.7
29-
- name: py38
42+
43+
- os: windows-latest
44+
name: py37-windows
45+
python-version: 3.7
46+
47+
- os: macOS-latest
48+
name: py37-mac
49+
python-version: 3.7
50+
51+
- os: ubuntu-18.04
52+
name: py38-ubuntu
3053
python-version: 3.8
31-
- name: py39
32-
python-version: 3.9
33-
- name: devel
54+
55+
- os: windows-latest
56+
name: py38-windows
57+
python-version: 3.8
58+
59+
- os: macOS-latest
60+
name: py38-mac
3461
python-version: 3.8
35-
- name: pypy3
62+
63+
- os: ubuntu-18.04
64+
name: py39-ubuntu
65+
python-version: 3.9
66+
67+
- os: windows-latest
68+
name: py39-windows
69+
python-version: 3.9
70+
71+
- os: macOS-latest
72+
name: py39-mac
73+
python-version: 3.9
74+
75+
- os: ubuntu-18.04
76+
name: pypy3-ubuntu
3677
python-version: pypy3
78+
79+
# Disabling due to https://github.com/actions/setup-python/issues/151
80+
# - os: windows-latest
81+
# name: pypy3-windows
82+
# python-version: pypy3
83+
84+
- os: macOS-latest
85+
name: pypy3-mac
86+
python-version: pypy3
87+
88+
- os: ubuntu-18.04
89+
name: devel-ubuntu
90+
python-version: 3.8
91+
3792
steps:
93+
- name: Set Newline Behavior
94+
run : |
95+
git config --global core.autocrlf false
3896
- uses: actions/checkout@master
3997
- name: Set up Python
4098
uses: actions/setup-python@v2
@@ -43,9 +101,15 @@ jobs:
43101
- name: Install tox
44102
run: |
45103
python -m pip install --upgrade tox
104+
- name: Get Tox Environment Name From Matrix Name
105+
uses: rishabhgupta/split-by@v1
106+
id: split-matrix-name
107+
with:
108+
string: '${{ matrix.name }}'
109+
split-by: '-'
46110
- name: Test with tox
47111
run: |
48-
python -m tox -e ${{ matrix.name }}
112+
python -m tox -e ${{ steps.split-matrix-name.outputs._0}}
49113
build_javascript:
50114
name: grunt
51115
runs-on: ubuntu-18.04

testing/test_pytest_html.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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
45
import json
56
import os
67
import random
@@ -12,6 +13,20 @@
1213

1314
pytest_plugins = ("pytester",)
1415

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+
1530

1631
def remove_deprecation_from_recwarn(recwarn):
1732
# TODO: Temporary hack until they fix

0 commit comments

Comments
 (0)