Skip to content

Commit

Permalink
CI(pytest): Run tests marked need_solo_run separately (#3879)
Browse files Browse the repository at this point in the history
* pytest: Create slow and needs_solo_run markers

* python: Apply needs_solo_run marker to two pygrass grid tests

* CI(pytest): Run tests marked need_solo_run separately with a single runner

* pytest: Revert timeout to 300 seconds
  • Loading branch information
echoix committed Jun 19, 2024
1 parent 9564852 commit afd7610
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@ jobs:
- name: Test executing of the grass command
run: .github/workflows/test_simple.sh

- name: Run pytest
- name: Run pytest with multiple workers in parallel
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
pytest --verbose --color=yes --durations=0 --durations-min=0.5 --numprocesses auto -ra .
pytest --verbose --color=yes --durations=0 --durations-min=0.5 --numprocesses auto -ra . -m 'not needs_solo_run'
- name: Run pytest with a single worker (for tests marked with needs_solo_run)
run: |
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
pytest --verbose --color=yes --durations=0 --durations-min=0.5 -ra . -m 'needs_solo_run'
- name: Print installed versions
if: always()
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ addopts = """
--ignore='raster/r.category/test_rcategory_doctest.txt'
"""
timeout = 300
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"needs_solo_run: marks tests that must be run without any other tests running in parallel",
]


[tool.bandit]
Expand Down
2 changes: 2 additions & 0 deletions python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def run_in_subprocess(function):
process.join()


@pytest.mark.needs_solo_run
@pytest.mark.parametrize("processes", list(range(1, max_processes() + 1)) + [None])
def test_processes(tmp_path, processes):
"""Check that running with multiple processes works"""
Expand Down Expand Up @@ -232,6 +233,7 @@ def run_grid_module():
assert info["min"] > 0


@pytest.mark.needs_solo_run
@pytest.mark.parametrize(
"processes, backend",
[
Expand Down

0 comments on commit afd7610

Please sign in to comment.