|
6 | 6 |
|
7 | 7 | from contextlib import nullcontext
|
8 | 8 | from datetime import datetime, timezone
|
9 |
| -from mne.io import RawArray |
10 |
| -from mne.io.meas_info import create_info |
| 9 | +from os import remove |
11 | 10 | from pathlib import Path
|
12 | 11 |
|
13 | 12 | import pytest
|
|
20 | 19 | from mne.datasets import testing, misc
|
21 | 20 | from mne.export import export_evokeds, export_evokeds_mff
|
22 | 21 | from mne.fixes import _compare_version
|
23 |
| -from mne.io import (read_raw_fif, read_raw_eeglab, read_raw_edf, |
| 22 | +from mne.io import (RawArray, read_raw_fif, read_raw_eeglab, read_raw_edf, |
24 | 23 | read_raw_brainvision)
|
| 24 | +from mne.io.meas_info import create_info |
25 | 25 | from mne.utils import (_check_eeglabio_installed, requires_version,
|
26 | 26 | object_diff, _check_edflib_installed, _resource_path,
|
27 | 27 | _check_pybv_installed, _record_warnings)
|
@@ -309,12 +309,23 @@ def test_export_raw_edf(tmp_path, dataset, format):
|
309 | 309 | temp_fname = tmp_path / f"test.{format}"
|
310 | 310 |
|
311 | 311 | # test runtime errors
|
312 |
| - with pytest.raises(RuntimeError, match='The maximum'), \ |
313 |
| - pytest.warns(RuntimeWarning, match='Data has a non-integer'): |
| 312 | + with pytest.warns() as record: |
314 | 313 | raw.export(temp_fname, physical_range=(-1e6, 0))
|
315 |
| - with pytest.raises(RuntimeError, match='The minimum'), \ |
316 |
| - pytest.warns(RuntimeWarning, match='Data has a non-integer'): |
| 314 | + if dataset == 'test': |
| 315 | + assert any( |
| 316 | + "Data has a non-integer" in str(rec.message) for rec in record |
| 317 | + ) |
| 318 | + assert any("The maximum" in str(rec.message) for rec in record) |
| 319 | + remove(temp_fname) |
| 320 | + |
| 321 | + with pytest.warns() as record: |
317 | 322 | raw.export(temp_fname, physical_range=(0, 1e6))
|
| 323 | + if dataset == 'test': |
| 324 | + assert any( |
| 325 | + "Data has a non-integer" in str(rec.message) for rec in record |
| 326 | + ) |
| 327 | + assert any("The minimum" in str(rec.message) for rec in record) |
| 328 | + remove(temp_fname) |
318 | 329 |
|
319 | 330 | if dataset == 'test':
|
320 | 331 | with pytest.warns(RuntimeWarning, match='Data has a non-integer'):
|
|
0 commit comments