Skip to content

Commit

Permalink
pytest: Temporary Working Directory
Browse files Browse the repository at this point in the history
Tests can generate temporary output and directories, which
might clash and/or need cleaning between tests.

This changes the current working directory to a unique
directory per test.
  • Loading branch information
ax3l committed Aug 28, 2023
1 parent b8e39ab commit c53e29c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@


@pytest.fixture(autouse=True, scope="function")
def amrex_init():
amr.initialize(
[
# print AMReX status messages
"amrex.verbose=2",
# throw exceptions and create core dumps instead of
# AMReX backtrace files: allows to attach to
# debuggers
"amrex.throw_exception=1",
"amrex.signal_handling=0",
# abort GPU runs if out-of-memory instead of swapping to host RAM
# "abort_on_out_of_gpu_memory=1",
]
)
def amrex_init(tmpdir):
with tmpdir.as_cwd():
amr.initialize(
[
# print AMReX status messages
"amrex.verbose=2",
# throw exceptions and create core dumps instead of
# AMReX backtrace files: allows to attach to
# debuggers
"amrex.throw_exception=1",
"amrex.signal_handling=0",
# abort GPU runs if out-of-memory instead of swapping to host RAM
# "abort_on_out_of_gpu_memory=1",
]
)
yield
amr.finalize()

Expand Down

0 comments on commit c53e29c

Please sign in to comment.