Skip to content

Commit 0b3b2eb

Browse files
authored
tests: Run gunittest-based tests with pytest that don’t require gunittest (#5584)
* pytest: Require pytest 8.2 * pytest: allow collecting more test files * pytest: Ignore collecting files in `testsuite/data` folders * pytest: Ignore running testsuite tests in normal runs * pytest: Run gunittest-based tests in a separate step in CI * CI(pytest): refactor pytest arguments into a file * pytest: remove common arg from gunittest args * pytest: Deselect crashing tests that use ctypes functions directly and note which tests run successfully * pytest: Extract gunittest deselect list to a separate arg file * pytest: ignore deprecated python/grass/temporal/unit_tests.py * CI(pytest): Run gunittest-based tests without default report args CI(pytest): Remove commented out ci args * CI(pytest): Show short traceback for gunittest-based tests * CI(pytest): Reset report list at end of run * CI(pytest): Only run passing gunittest-based tests * CI(OSGeo4w): Add folder of C:\OSGeo4W\opt\grass\grass85.bat to path for running gunittest-based tests with pytest * tests: Deselect non-fixed Windows test * CI(OSGeo4W): Use standard pytest args for running gunittest-based tests with pytest
1 parent 502ef94 commit 0b3b2eb

File tree

6 files changed

+74
-7
lines changed

6 files changed

+74
-7
lines changed

.github/workflows/macos.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,24 @@ jobs:
9797
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
9898
pytest \
9999
@.github/workflows/pytest_args_ci.txt \
100-
@.github/workflows/pytest_args_parallel.txt
100+
@.github/workflows/pytest_args_parallel.txt \
101+
-k 'not testsuite'
101102
- name: Run pytest with a single worker (for tests marked with needs_solo_run)
102103
shell: micromamba-shell {0}
103104
run: |
104105
export PYTHONPATH=$(grass --config python_path):$PYTHONPATH
105106
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
106107
pytest \
107108
@.github/workflows/pytest_args_ci.txt \
108-
@.github/workflows/pytest_args_not_parallel.txt
109+
@.github/workflows/pytest_args_not_parallel.txt \
110+
-k 'not testsuite'
111+
- name: Run pytest with a single worker (for gunittest-based tests)
112+
shell: micromamba-shell {0}
113+
run: |
114+
export PYTHONPATH=$(grass --config python_path):$PYTHONPATH
115+
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
116+
pytest \
117+
@.github/workflows/pytest_args_gunittest.txt
109118
110119
- name: Cache GRASS Sample Dataset
111120
id: cached-data

.github/workflows/osgeo4w.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,20 @@ jobs:
131131
call %OSGEO4W_ROOT%\opt\grass\etc\env.bat
132132
set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH%
133133
path %GISBASE%\lib;%GISBASE%\bin;%PATH%
134-
pytest @.github/workflows/pytest_args_ci.txt
134+
pytest ^
135+
@.github/workflows/pytest_args_ci.txt ^
136+
-k "not testsuite"
137+
shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}""
138+
- name: Run pytest with a single worker (for gunittest-based tests)
139+
run: |
140+
call %OSGEO4W_ROOT%\opt\grass\etc\env.bat
141+
set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH%
142+
path %GISBASE%\lib;%GISBASE%\bin;%PATH%;%OSGEO4W_ROOT%\opt\grass
143+
pytest ^
144+
@.github/workflows/pytest_args_ci.txt ^
145+
@.github/workflows/pytest_args_deselect.txt ^
146+
@.github/workflows/pytest_args_gunittest.txt ^
147+
--deselect=lib/init/testsuite/test_grass_tmp_mapset.py
135148
shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}""
136149

137150
- name: Run tests

.github/workflows/pytest.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ jobs:
9191
pytest \
9292
@.github/workflows/pytest_args_ci.txt \
9393
@.github/workflows/pytest_args_cov.txt \
94-
@.github/workflows/pytest_args_parallel.txt
94+
@.github/workflows/pytest_args_parallel.txt \
95+
-k 'not testsuite'
9596
9697
- name: Run pytest with a single worker (for tests marked with needs_solo_run)
9798
run: |
@@ -102,7 +103,17 @@ jobs:
102103
pytest \
103104
@.github/workflows/pytest_args_ci.txt \
104105
@.github/workflows/pytest_args_cov.txt \
105-
@.github/workflows/pytest_args_not_parallel.txt
106+
@.github/workflows/pytest_args_not_parallel.txt \
107+
-k 'not testsuite'
108+
- name: Run pytest with a single worker (for gunittest-based tests)
109+
run: |
110+
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
111+
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
112+
export INITIAL_GISBASE="$(grass --config path)"
113+
export INITIAL_PWD="${PWD}"
114+
pytest \
115+
@.github/workflows/pytest_args_cov.txt \
116+
@.github/workflows/pytest_args_gunittest.txt
106117
- name: Fix non-standard installed script paths in coverage data
107118
run: |
108119
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--deselect=imagery/i.signatures/testsuite/test_i_signatures.py
2+
--deselect=lib/gis/testsuite/gis_lib_env_test.py
3+
--deselect=lib/imagery/testsuite/test_imagery_find.py
4+
--deselect=lib/imagery/testsuite/test_imagery_sigfile.py
5+
--deselect=lib/imagery/testsuite/test_imagery_signature_management.py
6+
--deselect=lib/imagery/testsuite/test_imagery_sigsetfile.py
7+
--deselect=lib/raster/testsuite/test_raster_metadata.py
8+
--deselect=lib/vector/Vlib/testsuite/test_vlib_intersect.py
9+
--deselect=python/grass/pygrass/gis/testsuite/test_gis.py
10+
--deselect=python/grass/pygrass/modules/interface/testsuite/test_modules.py::TestModules
11+
--deselect=python/grass/pygrass/vector/testsuite/test_geometry.py
12+
--deselect=python/grass/pygrass/vector/testsuite/test_geometry_attrs.py
13+
--deselect=python/grass/pygrass/vector/testsuite/test_vector.py
14+
--deselect=python/grass/pygrass/vector/testsuite/test_vector3d.py
15+
--deselect=raster/r.support/testsuite/test_r_support.py
16+
--deselect=scripts/r.semantic.label/testsuite/test_r_semantic_label.py
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--ignore-glob=**/tests/**
2+
--ignore=gui/
3+
--ignore=python/grass/temporal/unit_tests.py
4+
lib/gis/testsuite/test_gis_lib_getl.py
5+
lib/init/testsuite/test_grass_tmp_mapset.py
6+
lib/vector/Vlib/testsuite/test_vlib_box.py
7+
python/grass/exceptions/testsuite/test_ScriptError.py
8+
python/grass/gunittest/testsuite/test_checkers.py
9+
python/grass/pygrass/modules/interface/testsuite/test_flag.py
10+
python/grass/pygrass/modules/interface/testsuite/test_parameter.py
11+
python/grass/pygrass/vector/testsuite/test_filters.py
12+
python/grass/script/testsuite/test_core_make_val.py
13+
python/grass/script/testsuite/test_utils.py

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ addopts = """
353353
--ignore-glob='dist.*'
354354
--ignore-glob='bin.*'
355355
--ignore-glob='*/tests/data/*'
356+
--ignore-glob='*/testsuite/data/**'
356357
--ignore-glob='*/grass/pygrass/tests/*'
357358
--doctest-glob='*doctest*.txt'
358359
--ignore='raster/r.category/test_rcategory_doctest.txt'
@@ -361,8 +362,12 @@ markers = [
361362
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
362363
"needs_solo_run: marks tests that must be run without any other tests running in parallel",
363364
]
364-
minversion = "6.0"
365-
python_files = "*/tests/*_test.py */tests/test_*.py"
365+
minversion = "8.2"
366+
python_files = """
367+
*/tests/*_test.py
368+
*/tests/test_*.py
369+
**/testsuite/*test*.py
370+
"""
366371
timeout = 300
367372

368373

0 commit comments

Comments
 (0)