-
Notifications
You must be signed in to change notification settings - Fork 107
Pytest integrated #3331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tomc271
wants to merge
170
commits into
next
Choose a base branch
from
pytest-integrated
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Pytest integrated #3331
Changes from all commits
Commits
Show all changes
170 commits
Select commit
Hold shift + click to select a range
a102ffe
Use pytest rather than runtest as the command set in bout_add_integra…
tomchapman a55dda0
Rename runtest file to test-foo.py for each integrated test
tomchapman 053f62a
Rename runtest file to test-foo.py for each MMS test
tomchapman db34143
Convert runtest file to use pytest for test_drift_instability
tomchapman 0ed0750
Handle test files for tests named either `test-foo` or `foo`
tomchapman fdd93e0
Handle test files with hyphens or prefixed with
tomchapman f0b4405
Update symlink to renamed runtest file
tomchapman 4dd41cc
Rename more runtest files
tomchapman 0fa8b81
Change filename Test run by tpc522 on Mon Nov 3 17:45:34 2025
tomchapman f9e2374
Rename more runtest files
tomchapman d00629c
Use PATH-based pytest executable
tomchapman 393ac3e
Fix more renamings
tomchapman 4deaf22
Change custom_target check-integrated-tests to use pytest instead of …
tomchapman 82ff7ca
Some `runtest` files are shell scripts not python scripts, so revert …
tomchapman 681c2fb
Add python tests to run those `runtest` files that are not python scr…
tomchapman 01cc49c
Convert test_cyclic.py to a valid pytest file
tomchapman 09114fe
Convert several more test files to work with pytest
tomchapman be04639
Change directory before calling `boutpp.init()`
tomchapman abe75f2
Change directory before calling `boutpp.init()`
tomchapman 52436a8
Change directory before calling `boutpp.Field3D.fromCollect()`
tomchapman f7378bc
Modify more test files for running via pytest
tomchapman 5a959a2
MPI oversubscribe for communications test
tomchapman e977ed6
Change directory before removing files in `data` directory
tomchapman 9afb0b2
Modify test_communications to run via pytest
tomchapman 18b9c90
Modify test_delp2 to run via pytest
tomchapman c55ab8f
Modify test_fci_boundary to run via pytest
tomchapman 125dd80
Modify test_fieldgroupcomm to run via pytest
tomchapman ede926e
Modify test_gyro to run via pytest
tomchapman cc47c24
Modify test_interpolate to run via pytest
tomchapman 79204e5
Modify test_multigrid_laplace to run via pytest
tomchapman a4ebe18
Modify test_laplace to run via pytest
tomchapman fc99e0d
Modify test_interpolate_z to run via pytest
tomchapman a961978
Modify test_interchange_instability to run via pytest
tomchapman 0e87bf4
Modify test_naulin_laplace to run via pytest
tomchapman 869ba61
Modify test_options_netcdf to run via pytest
tomchapman 47a9596
Modify test_restart_io to run via pytest
tomchapman 7dbb5a7
Modify test_restarting to run via pytest
tomchapman 8d87bda
Modify test_smooth to run via pytest
tomchapman e3bb3cd
Modify test_squash to run via pytest
tomchapman c6e02eb
Add conftest.py, with contextmanager `chdir` and fixture `test_dir`
tomchapman 9b63aaf
Use contextmanager `chdir` in tests
tomchapman e3e853c
Use monkeypatch.chdir() fixture instead of contextmanager
tomchapman 0cfa087
Modify test_twistshift to run via pytest
tomchapman 27d8225
Modify test_twistshift_staggered to run via pytest
tomchapman 715babf
Modify test_vec to run via pytest
tomchapman fe49bef
Add `OMPI_MCA_rmaps_base_oversubscribe` environment variable in test_…
tomchapman ada42eb
Modify test_stopCheck_file to run via pytest
tomchapman c0a1e2c
Modify test_yupdown_weights to run via pytest
tomchapman 9be45a4
Modify test_griddata_yboundary_guards to run via pytest
tomchapman f8d07da
Use monkeypatch.chdir() fixture instead of contextmanager
tomchapman d81e62f
Remove build_and_log() calls
tomchapman bcbd7d8
Copy conftest.py when building
tomchapman 666835f
Correct assert statement in test_boutpp_collect_staggered
tomchapman c748b9c
Now have a fixture that handles changing the working directory for ea…
tomchapman 5c3488d
Fix "Copy conftest.py when building"
tomchapman f8f83cc
Add `finalize_boutpp` fixture, and mark relevant tests with a `boutpp…
tomchapman 13c3be5
Add `finalize_boutpp` fixture, and mark relevant tests with a `boutpp…
tomchapman 68d0583
Add fixture `xdist_each` for boutpp tests
tomchapman 5eede91
Add fixture `make_dir_and_copy_input`
tomchapman f59b194
Rename `make_dir_and_copy_input` fixture to `copy_data_directory`
tomchapman 595b0b7
Add pytest marker `input_dir`
tomchapman 4fd9bc6
Fix testDirectoryArgumentNonDirectory
tomchapman 3a3c23b
Mark more tests with `input_dir`
tomchapman f964b09
Combine fixtures `cwd_to_test_file_dir` and `copy_data_directory` int…
tomchapman 5069936
Mark test_boutpp_collect with input_dir(name="input")
tomchapman 01f6c87
`finalize_boutpp` fixture not needed now that using xdist_group
tomchapman d08672f
Copy and cwd to tmp_dir
tomchapman 2374566
Fix test_datafile_facade
tomchapman cac189b
Fix assert in test_invpar
tomchapman a429e6d
Remove input_dir(name="input") markers
tomchapman 0c67687
Restore CMake copying `runtest` files
tomchapman b4bb8fc
Use tmp_path_factory to ensure a unique temp dir for each test
tomchapman 4129021
Don't change to test directory now that there is a fixture that switc…
tomchapman 10b1d82
Fix CMakeLists.txt for test-fci-boundary
tomchapman 534163b
Add newline at end of file
tomchapman e6a15ea
Don't change to test directory now that there is a fixture that switc…
tomchapman e0722af
Copy test-boutpp/conftest.py when building
tomchapman 93737b5
Add missing fixture argument `test_dir`
tomchapman 91aede7
Add run_integrated_tests.sh
tomchapman 1e8b9f2
Fix addinivalue_line "serial" in `pytest_configure` hook
tomchapman 72d1605
Remove ini value for `input_dir` mark in `pytest_configure` hook
tomchapman 73d8b06
Copy tests/run_integrated_tests.sh when building
tomchapman eb35e01
Modify test_laplace_petsc3d to run via pytest
tomchapman b30a71f
Use pathlib instead of os.path
tomchapman e820b8f
Revert "Use pytest rather than runtest as the command set in bout_add…
tomchapman 472d6fb
Copy `runtest` file even if not `USE_RUNTEST`
tomchapman 39b292f
Extract duplicated code to a fixture `run_in_terminal`
tomchapman 3d92158
Path.exists() takes a Path object
tomchapman b9ad55c
Always copy test file when building
tomchapman 95a5a04
Handle parsing test name for those already prefixed with "test_"
tomchapman a3d8a55
Fix test_beuler and test_solver
tomchapman d58ba64
Refactor fixture `assert_success_in_shell` to return a function
tomchapman abd771d
Modify test-fci-mpi to run via pytest
tomchapman a4d97ab
Modify test-subdir to run via pytest
tomchapman a104a82
Modify test_globalfield to run via pytest
tomchapman dc2ac7b
Modify test_integrate to run via pytest
tomchapman 2f0422e
Modify test_laplacexy_fv to run via pytest
tomchapman 75e3f7f
Modify test_laplace2 to run via pytest
tomchapman 6392849
Modify test_laplacexy to run via pytest
tomchapman 4bc9c67
Modify test_laplace_hypre3d to run via pytest
tomchapman f23ec42
Modify test_invertable_operator to run via pytest
tomchapman 3ad7e13
Correct function name `test_fci_mpi()`
tomchapman 45041cb
Modify test_collect to run via pytest
tomchapman 04f4b92
Modify test_dataformat to run via pytest
tomchapman 41f7434
Remove obsolete scripts for running tests via autotools
tomchapman b0ebaa9
Fix merge error.
tomchapman 7e32a45
Modify test_laplacexy2_hypre to run via pytest
tomchapman 621fbe1
Modify test_petsc_laplace to run via pytest
tomchapman 5a90ffa
Modify test_petsc_laplace_MAST_grid to run via pytest
tomchapman 478e2a4
Modify test_region_iterator to run via pytest
tomchapman 9756e1d
Remove unused import
tomchapman 241e790
Fix CMakeLists.txt for `test_fci_mpi`
tomchapman ca85ceb
Fix test_backtrace
tomchapman 22ec152
Convert test_boutpp_print to from a shell script to python
tomchapman cc5c273
Skip test_fci_boundary if zoidberg not found
tomchapman 4fc666d
Add boutpp location to PYTHONPATH before running pytest
tomchapman 74b5fa0
Pass through to pytest additional arguments given to run_integrated_t…
tomchapman c99c2f5
Fix test_boutpp_print (don't split msg)
tomchapman 0b3d631
Set absolute path to boupp in PYTHONPATH
tomchapman 45292e3
Add the pytest option console_output_style = "plain" to pyproject.toml
tomchapman d44ec6a
Copy pyproject.toml file when building
tomchapman 585aaf7
Pre-build the project to prevent concurrent CMake race conditions
tomchapman ba32f9f
Fix copying the pyproject.toml file
tomchapman 1e800fe
add quiet option to pytest command, to prevent concurrent console out…
tomchapman 7b459b7
Use the absolute path to the `integrated` directory
tomchapman 4681b19
Refactor run_integrated_tests.sh (to use `PROJECT_ROOT`)
tomchapman 7cefd0a
Revert rename of MMS `runtest` files
tomchapman a48c093
Revert inclusion of MMS tests when copying test files to build
tomchapman 94c11c8
Make cmake test file copying apply only to integrated tests
tomchapman 07aa431
Revert "Rename runtest file to test-foo.py for each MMS test"
tomchapman b22da30
Revert "Change filename Test run by tpc522 on Mon Nov 3 17:45:34 2025"
tomchapman e6f9cb7
Convert test_laplacexy_short to run via pytest
tomchapman 3d19303
Convert test_laplacexz to run via pytest
tomchapman 07d7add
Convert test_slepc_solver to run via pytest
tomchapman dd003e5
Only copy test files if test has not been skipped
tomchapman b9841d1
Update .ci_with_cmake.sh to use the cmake target that correctly handl…
tomchapman 2b9d46a
Update the command set in BOUT++functions.cmake to make ctest use pyt…
tomchapman 1953565
Let cmake's configure_file command insert the build directory path in…
tomchapman 81631d5
Fix rebase errors
tomchapman ffa90b2
Revert "Rename runtest file to test-foo.py for each MMS test"
tomchapman 4fd66d7
Add pytest to requirements.txt
tomchapman 4bca28c
Add boutpp location to PYTHONPATH when launching pytest through cmake…
tomchapman a42bc36
Fix test_laplace after rebase
tomchapman 3f99cce
Use BOUT_PYTHONPATH instead of PROJECT_BINARY_DIR
tomchapman 7822ca9
Make check-integrated-tests target just run the `run_integrated_tests…
tomchapman a2e6bb4
Don't rely on BOUT_PYTHONPATH, as not available always
tomchapman 6fceadd
Remove unused boutpp import from conftest.py
tomchapman bf5e02b
Add pytest-xdist to requirements.txt
tomchapman b28b5a5
Fix pytest command not found in CI by using `python3 -m pytest`
tomchapman 8852248
Use the Python executable that CMake discovered during configuration
tomchapman 82bbe9f
Add OpenMPI oversubscription overrides
tomchapman f72de98
Install pytest in fedora ci script
tomchapman a60fdc0
Add pytest and pytest-xdist to pyproject.toml
tomchapman c2ef619
Use uv sync instead of pip install, in github `tests` workflow
tomchapman 5af0f19
Add no-install-project option to uv command
tomchapman b5509a9
Add no-dev option to uv command in github workflow
tomchapman 7b33082
Install python, pip, pytest, numpy, and scipy through uv
tomchapman 7c4b0a9
Set VIRTUAL_ENV to force CMake to recognize the virtual environment
tomchapman b34d4fb
Pass DPython3_EXECUTABLE to cmake script, to force it to use the venv
tomchapman 8389802
Install the core requirements
tomchapman 967bb07
Remove numpy and scipy from pytest dependency-group in pyproject.toml
tomchapman 9b87d16
Merge branch 'uv-for-pytest' into pytest-integrated
tomchapman e05bd51
Reinstate timeout for tests
tomchapman 30b5223
Simplify `Path.exists()` expressions
tomchapman becb76c
Remove previously deleted test
tomchapman a1c67ff
Prefer numpy.testing.assert_allclose
tomchapman 9ff2e14
Add fail-fast option to run_integrated_tests.sh
tomchapman 235c524
Add autouse fixture to call boutpp.finalise()
tomchapman 0917c92
Fix test_fci_boundary
tomchapman 87931a7
Run pytest verbosely when CI flag is true
tomchapman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import pytest | ||
| import shutil | ||
| import os | ||
| import subprocess | ||
| import time | ||
| from pathlib import Path | ||
|
|
||
|
|
||
|
|
||
| def pytest_configure(config): | ||
| config.addinivalue_line( | ||
| "markers", "serial: mark that the test should not be run concurrently with other. " | ||
| ) | ||
|
|
||
| @pytest.fixture | ||
| def test_dir(request) -> Path: | ||
| return Path(request.fspath).parent | ||
|
|
||
| @pytest.fixture(scope="function", autouse=True) | ||
| def copy_and_cwd_to_unique_tmp_dir(request, tmp_path_factory, monkeypatch): | ||
| """ | ||
| For each test function, create a unique temporary copy of the test directory | ||
| and change cwd to it. | ||
| """ | ||
|
|
||
| test_file_dir = Path(request.fspath).parent | ||
|
|
||
| if not test_file_dir.is_dir(): | ||
| pytest.fail(f"Expected test directory '{test_file_dir}' not found") | ||
|
|
||
| # Create a unique temp dir for this test | ||
| run_dir = tmp_path_factory.mktemp(test_file_dir.name) | ||
|
|
||
| # Copy the original test directory into it | ||
| shutil.copytree(test_file_dir, run_dir, dirs_exist_ok=True) | ||
|
|
||
| # Change working directory to the copy | ||
| monkeypatch.chdir(run_dir) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def assert_success_in_shell(test_dir): | ||
|
|
||
| def inner_function(command: str): | ||
| # MPI oversubscribe for communications test | ||
| os.environ["OMPI_MCA_rmaps_base_oversubscribe"] = "1" # Allows 18 procs | ||
| start = time.time() | ||
| result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=600) | ||
| elapsed = time.time() - start | ||
| assert result.returncode == 0, (f"Failed after {elapsed:.3f}s in {test_dir}\n" | ||
| f"Stderr: {result.stderr}\n" | ||
| f"Output: {result.stdout}") | ||
|
|
||
| return inner_function |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env python3 | ||
| import pytest | ||
| # Test enabling/disabling exception backtrace from environment variable | ||
|
|
||
| # requires all_tests | ||
|
|
||
| from boututils.run_wrapper import shell | ||
| import os | ||
|
|
||
|
|
||
| def test_backtrace(): | ||
| try: | ||
| del os.environ["BOUT_SHOW_BACKTRACE"] | ||
| except KeyError: | ||
| pass | ||
|
|
||
| _, output = shell(["BOUT_SHOW_BACKTRACE=0 ./boutexcept"], pipe=True) | ||
|
|
||
| assert "troublemaker" not in output, f"Fail: detected offending function name in output when not expected\n{output}" | ||
|
|
||
| _, output = shell(["./boutexcept"], pipe=True) | ||
|
|
||
| assert "troublemaker" in output, f"Fail: did not detect offending function name in output when expected\n{output}" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.