switch "manual" tempdirs for testing to pytest tmpdir fixtures
sappelhoff opened this issue · comments
Stefan Appelhoff commented
Making use of this feature: https://docs.pytest.org/en/stable/tmpdir.html
Replacing this code:
pybv/pybv/tests/test_bv_writer.py
Lines 103 to 113 in 54da125
... with the following:
@pytest.mark.parametrize("meas_date,match",
[(1, '`meas_date` must be of type str, datetime'),
('', 'Got a str for `meas_date`, but it was'),
('1973', 'Got a str for `meas_date`, but it was')])
+ def test_bad_meas_date(tmpdir, meas_date, match):
"""Test that bad measurement dates raise errors."""
- tmpdir = _mktmpdir()
with pytest.raises(ValueError, match=match):
write_brainvision(data, sfreq, ch_names, fname, tmpdir,
meas_date=meas_date)
- rmtree(tmpdir)
This would clean up the code by a bit and follow best practice for pytest.