Skip to content

Commit

Permalink
Approach using arguments to pytest.
Browse files Browse the repository at this point in the history
  • Loading branch information
facundobatista committed Jul 16, 2024
1 parent c55cfa6 commit 35fde61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/integtests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
bin/fades -v -d pytest -x pytest --version
- name: Using a different Python
run: |
export TEST_PYTHON_VERSION=3.9
python bin/fades -v --python=python3.9 -d pytest -x pytest -v tests/integtest.py
python bin/fades -v --python=python3.9 -d pytest -x pytest -v --integtest-pyversion=3.9 tests/integtest.py
fedora:
runs-on: ubuntu-latest
Expand All @@ -54,8 +53,7 @@ jobs:
run: |
yum install --assumeyes python3.9
cd /fades
export TEST_PYTHON_VERSION=3.9
python3.12 bin/fades -v --python=python3.9 -d pytest -x pytest -v tests/integtest.py
python3.12 bin/fades -v --python=python3.9 -d pytest -x pytest -v --integtest-pyversion=3.9 tests/integtest.py
native-windows:
strategy:
Expand Down Expand Up @@ -91,7 +89,7 @@ jobs:
- name: Using a different Python
run: |
TEST_PYTHON_VERSION=3.10 ${{ steps.matrixpy.outputs.python-path }} bin/fades -v --python=${{ steps.otherpy.outputs.python-path }} -d pytest -x pytest -v tests/integtest.py
${{ steps.matrixpy.outputs.python-path }} bin/fades -v --python=${{ steps.otherpy.outputs.python-path }} -d pytest -x pytest -v --integtest-pyversion=3.10 tests/integtest.py
native-generic:
strategy:
Expand Down Expand Up @@ -126,5 +124,4 @@ jobs:
- name: Using a different Python
run: |
export TEST_PYTHON_VERSION=3.10
${{ steps.matrixpy.outputs.python-path }} bin/fades -v --python=python3.10 -d pytest -x pytest -v tests/integtest.py
${{ steps.matrixpy.outputs.python-path }} bin/fades -v --python=python3.10 -d pytest -x pytest -v --integtest-pyversion=3.10 tests/integtest.py
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ def add_content(lines):

yield add_content
shutil.rmtree(str(dir_path))


def pytest_addoption(parser):
"""Define new pytest command line argument to be used by integration tests."""
parser.addoption("--integtest-pyversion", action="store")
4 changes: 2 additions & 2 deletions tests/integtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import sys


def test_assert_python_version():
expected = os.environ.get("TEST_PYTHON_VERSION")
def test_assert_python_version(pytestconfig):
expected = pytestconfig.getoption("integtest_pyversion")
vi = sys.version_info
current = f"{vi.major}.{vi.minor}"
assert current == expected

0 comments on commit 35fde61

Please sign in to comment.