diff --git a/package/CHANGELOG b/package/CHANGELOG index 2f51f4c37e6..70b504d22f5 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -58,6 +58,8 @@ Fixes Universe (PR #2893) * ensure that unistd.h is included on macOS when compiling ENCORE's spe.c (Issue #2934) + * Fix tests for analysis.bat that could fail when run in parallel and that + would create a test artifact (Issue #2979, PR #2981) Enhancements * Refactored analysis.helanal into analysis.helix_analysis diff --git a/testsuite/MDAnalysisTests/analysis/test_bat.py b/testsuite/MDAnalysisTests/analysis/test_bat.py index 36ef684319b..9fb0e93b977 100644 --- a/testsuite/MDAnalysisTests/analysis/test_bat.py +++ b/testsuite/MDAnalysisTests/analysis/test_bat.py @@ -45,6 +45,14 @@ def bat(self, selected_residues): R.run() return R.bat + @pytest.fixture + def bat_npz(self, tmpdir, selected_residues): + filename = str(tmpdir / 'test_bat_IO.npy') + R = BAT(selected_residues) + R.run() + R.save(filename) + return filename + def test_bat_root_selection(self, selected_residues): R = BAT(selected_residues) assert_equal(R._root.indices, [8, 2, 1], @@ -79,11 +87,8 @@ def test_bat_reconstruction(self, selected_residues, bat): err_msg="error: Reconstructed Cartesian coordinates " + \ "don't match original") - def test_bat_IO(self, selected_residues, bat): - R = BAT(selected_residues) - R.run() - R.save('test_bat_IO.npy') - R2 = BAT(selected_residues, filename='test_bat_IO.npy') + def test_bat_IO(self, bat_npz, selected_residues, bat): + R2 = BAT(selected_residues, filename=bat_npz) test_bat = R2.bat assert_almost_equal( bat, @@ -107,8 +112,8 @@ def test_bat_disconnected_atom_group(self): with pytest.raises(ValueError): R = BAT(selected_residues) - def test_bat_incorrect_dims(self): + def test_bat_incorrect_dims(self, bat_npz): u = mda.Universe(PSF, DCD) selected_residues = u.select_atoms("resid 1-3") with pytest.raises(ValueError): - R = BAT(selected_residues, filename='test_bat_IO.npy') + R = BAT(selected_residues, filename=bat_npz)