1 """Configuration and fixtures for pytest."""
9 """Provide a clean working directory for tests.
16 @pytest.mark.usefixtures("cleandir")
17 class TestDirectoryInit(object):
18 def test_cwd_starts_empty(self):
19 assert os.listdir(os.getcwd()) == []
20 with open("myfile", "w") as f:
23 def test_cwd_again_starts_empty(self):
24 assert os.listdir(os.getcwd()) == []
26 Ref: https://docs.pytest.org/en/latest/fixture.html#using-fixtures-from-classes-modules-or-projects
28 newpath
= tempfile
.mkdtemp()
33 from mpi4py
import MPI
34 withmpi_only
= pytest
.mark
.skipif(not MPI
.Is_initialized() or MPI
.COMM_WORLD
.Get_size() < 2,
35 reason
="Test requires at least 2 MPI ranks, but MPI is not initialized or too small.")
37 withmpi_only
= pytest
.mark
.skip(reason
="Test requires at least 2 MPI ranks, but mpi4py is not available.")
41 """Provide a sample TPR file by filename."""
42 current_dir
= os
.path
.dirname(__file__
)
43 file_path
= os
.path
.join(current_dir
, 'topol.tpr')
44 return os
.path
.abspath(file_path
)