MCPcopy
hub / github.com/mne-tools/mne-python / test_check

Function test_check

mne/utils/tests/test_check.py:51–77  ·  view source on GitHub ↗

Test checking functions.

(tmp_path)

Source from the content-addressed store, hash-verified

49
50@testing.requires_testing_data
51def test_check(tmp_path):
52 """Test checking functions."""
53 pytest.raises(ValueError, check_random_state, "foo")
54 pytest.raises(TypeError, _check_fname, 1)
55 _check_fname(Path("./foo"))
56 fname = tmp_path / "foo"
57 with open(fname, "wb"):
58 pass
59 assert fname.is_file()
60 _check_fname(fname, overwrite="read", must_exist=True)
61 orig_perms = os.stat(fname).st_mode
62 os.chmod(fname, 0)
63 if not sys.platform.startswith("win"):
64 with pytest.raises(PermissionError, match="read permissions"):
65 _check_fname(fname, overwrite="read", must_exist=True)
66 os.chmod(fname, orig_perms)
67 os.remove(fname)
68 assert not fname.is_file()
69 pytest.raises(OSError, check_fname, "foo", "tets-dip.x", (), (".fif",))
70 pytest.raises(ValueError, _check_subject, None, None)
71 pytest.raises(TypeError, _check_subject, None, 1)
72 pytest.raises(TypeError, _check_subject, 1, None)
73 # smoke tests for permitted types
74 check_random_state(None).choice(1)
75 check_random_state(0).choice(1)
76 check_random_state(np.random.RandomState(0)).choice(1)
77 check_random_state(np.random.default_rng(0)).choice(1)
78
79
80@testing.requires_testing_data

Callers

nothing calls this directly

Calls 3

_check_fnameFunction · 0.90
check_random_stateFunction · 0.90
removeMethod · 0.45

Tested by

no test coverage detected