From 73fdc7addc29b7877ee3915d0aad197aa3a6e16a Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Sat, 23 Nov 2024 17:43:14 +0000 Subject: [PATCH] Drop unnecessary config --- test/conftest.py | 95 ------------------------------------------------ 1 file changed, 95 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index d869b780..3675a4e0 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -4,58 +4,6 @@ **Disclaimer: some functions copied from firedrake/src/tests/conftest.py """ -from subprocess import check_call - - -def parallel(item): - """ - Run a test in parallel. - - **Disclaimer: copied from firedrake/src/tests/conftest.py - - :arg item: the test item to run. - """ - from mpi4py import MPI - - if MPI.COMM_WORLD.size > 1: - raise RuntimeError("Parallel test can't be run within parallel environment") - marker = item.get_closest_marker("parallel") - if marker is None: - raise RuntimeError("Parallel test doesn't have parallel marker") - nprocs = marker.kwargs.get("nprocs", 3) - if nprocs < 2: - raise RuntimeError("Need at least two processes to run parallel test") - - # Only spew tracebacks on rank 0. - # Run xfailing tests to ensure that errors are reported to calling process. - call = [ - "mpiexec", - "-n", - "1", - "python", - "-m", - "pytest", - "--runxfail", - "-s", - "-q", - "%s::%s" % (item.fspath, item.name), - ] - call.extend( - [ - ":", - "-n", - "%d" % (nprocs - 1), - "python", - "-m", - "pytest", - "--runxfail", - "--tb=no", - "-q", - "%s::%s" % (item.fspath, item.name), - ] - ) - check_call(call) - def pytest_configure(config): """ @@ -63,55 +11,12 @@ def pytest_configure(config): **Disclaimer: copied from firedrake/src/tests/conftest.py """ - config.addinivalue_line( - "markers", - "parallel(nprocs): mark test to run in parallel on nprocs processors", - ) config.addinivalue_line( "markers", "slow: mark test as slow to run", ) -def pytest_runtest_setup(item): - """ - **Disclaimer: copied from firedrake/src/tests/conftest.py - """ - if item.get_closest_marker("parallel"): - from mpi4py import MPI - - if MPI.COMM_WORLD.size > 1: - # Turn on source hash checking - from functools import partial - - from firedrake import parameters - - def _reset(check): - parameters["pyop2_options"]["check_src_hashes"] = check - - # Reset to current value when test is cleaned up - item.addfinalizer( - partial(_reset, parameters["pyop2_options"]["check_src_hashes"]) - ) - - parameters["pyop2_options"]["check_src_hashes"] = True - else: - # Blow away function arg in "master" process, to ensure - # this test isn't run on only one process. - item.obj = lambda *args, **kwargs: True - - -def pytest_runtest_call(item): - """ - **Disclaimer: copied from firedrake/src/tests/conftest.py - """ - from mpi4py import MPI - - if item.get_closest_marker("parallel") and MPI.COMM_WORLD.size == 1: - # Spawn parallel processes to run test - parallel(item) - - def pytest_runtest_teardown(item, nextitem): """ Clear caches after running a test