Skip to content

Commit 6395ece

Browse files
committed
Test conditional collection on PyPy and CPython
1 parent f4a88d6 commit 6395ece

File tree

5 files changed

+36
-14
lines changed

5 files changed

+36
-14
lines changed

.github/workflows/examples.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14+
python-version: ["pypy-3.7", "3.9"]
1415
target: [
1516
"src-layout",
1617
"adhoc-layout",
1718
]
18-
19+
include:
20+
# Add new helper variables to existing jobs
21+
- {python-version: "pypy-3.7", tox-python-version: "pypy3"}
22+
- {python-version: "3.9", tox-python-version: "py39"}
1923
steps:
2024
- uses: actions/checkout@v2
2125

22-
- name: Set up Python
26+
- name: Set up Python ${{ matrix.python-version }}
2327
uses: actions/setup-python@v2
2428
with:
25-
python-version: 3.9
29+
python-version: ${{ matrix.python-version }}
2630

2731
- name: Cache
2832
uses: actions/cache@v2
@@ -42,4 +46,4 @@ jobs:
4246
- name: Examples
4347
run: |
4448
cd examples/${{ matrix.target }}
45-
tox -v
49+
tox -v -e ${{ matrix.tox-python-version }}
+11-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
def add(a, b):
2-
return a + b
1+
import platform
2+
3+
# test merging multiple tox runs with a platform
4+
# based branch
5+
if platform.python_implementation() == "PyPy":
6+
def add(a, b):
7+
return a + b
8+
9+
else:
10+
def add(a, b):
11+
return a + b

examples/adhoc-layout/tox.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[tox]
2-
envlist = py38,report
2+
envlist = pypy3,py39,report
33

44
[tool:pytest]
55
addopts =
66
--cov-report=term-missing
77

88
[testenv]
99
setenv =
10-
py38: COVERAGE_FILE = .coverage.{envname}
10+
py{py3,39}: COVERAGE_FILE = .coverage.{envname}
1111
commands = pytest --cov --cov-config={toxinidir}/.coveragerc {posargs:-vv}
1212
deps =
1313
pytest
@@ -19,7 +19,7 @@ deps =
1919
../..
2020

2121
depends =
22-
report: py38
22+
report: pypy3,py39
2323

2424
# note that this is necessary to prevent the tests importing the code from your badly laid project
2525
changedir = tests
+11-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
def add(a, b):
2-
return a + b
1+
import platform
2+
3+
# test merging multiple tox runs with a platform
4+
# based branch
5+
if platform.python_implementation() == "PyPy":
6+
def add(a, b):
7+
return a + b
8+
9+
else:
10+
def add(a, b):
11+
return a + b

examples/src-layout/tox.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py38,report
2+
envlist = pypy3,py39,report
33

44
[tool:pytest]
55
testpaths = tests
@@ -8,7 +8,7 @@ addopts =
88

99
[testenv]
1010
setenv =
11-
py38: COVERAGE_FILE = .coverage.{envname}
11+
py{py3,39}: COVERAGE_FILE = .coverage.{envname}
1212
commands = pytest --cov {posargs:-vv}
1313
deps =
1414
pytest
@@ -20,7 +20,7 @@ deps =
2020
../..
2121

2222
depends =
23-
report: py38
23+
report: pypy3,py39
2424

2525
[testenv:report]
2626
skip_install = true

0 commit comments

Comments
 (0)