Skip to content

Commit

Permalink
Test conditional collection on PyPy and CPython
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 21, 2021
1 parent f4a88d6 commit 6395ece
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/examples.yml
Expand Up @@ -11,18 +11,22 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["pypy-3.7", "3.9"]
target: [
"src-layout",
"adhoc-layout",
]

include:
# Add new helper variables to existing jobs
- {python-version: "pypy-3.7", tox-python-version: "pypy3"}
- {python-version: "3.9", tox-python-version: "py39"}
steps:
- uses: actions/checkout@v2

- name: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}

- name: Cache
uses: actions/cache@v2
Expand All @@ -42,4 +46,4 @@ jobs:
- name: Examples
run: |
cd examples/${{ matrix.target }}
tox -v
tox -v -e ${{ matrix.tox-python-version }}
13 changes: 11 additions & 2 deletions examples/adhoc-layout/example/__init__.py
@@ -1,2 +1,11 @@
def add(a, b):
return a + b
import platform

# test merging multiple tox runs with a platform
# based branch
if platform.python_implementation() == "PyPy":
def add(a, b):
return a + b

else:
def add(a, b):
return a + b
6 changes: 3 additions & 3 deletions examples/adhoc-layout/tox.ini
@@ -1,13 +1,13 @@
[tox]
envlist = py38,report
envlist = pypy3,py39,report

[tool:pytest]
addopts =
--cov-report=term-missing

[testenv]
setenv =
py38: COVERAGE_FILE = .coverage.{envname}
py{py3,39}: COVERAGE_FILE = .coverage.{envname}
commands = pytest --cov --cov-config={toxinidir}/.coveragerc {posargs:-vv}
deps =
pytest
Expand All @@ -19,7 +19,7 @@ deps =
../..

depends =
report: py38
report: pypy3,py39

# note that this is necessary to prevent the tests importing the code from your badly laid project
changedir = tests
Expand Down
13 changes: 11 additions & 2 deletions examples/src-layout/src/example/__init__.py
@@ -1,2 +1,11 @@
def add(a, b):
return a + b
import platform

# test merging multiple tox runs with a platform
# based branch
if platform.python_implementation() == "PyPy":
def add(a, b):
return a + b

else:
def add(a, b):
return a + b
6 changes: 3 additions & 3 deletions examples/src-layout/tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py38,report
envlist = pypy3,py39,report

[tool:pytest]
testpaths = tests
Expand All @@ -8,7 +8,7 @@ addopts =

[testenv]
setenv =
py38: COVERAGE_FILE = .coverage.{envname}
py{py3,39}: COVERAGE_FILE = .coverage.{envname}
commands = pytest --cov {posargs:-vv}
deps =
pytest
Expand All @@ -20,7 +20,7 @@ deps =
../..

depends =
report: py38
report: pypy3,py39

[testenv:report]
skip_install = true
Expand Down

0 comments on commit 6395ece

Please sign in to comment.