Skip to content

Commit

Permalink
Don't use keyword 'match' as variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
berquist committed Sep 10, 2023
1 parent e408b16 commit 7fadf04
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
42 changes: 21 additions & 21 deletions tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ def test_close_group(setup_teardown_file):
assert 'dataset' not in f

# unable to create new stuff
match = "Unable to operate on closed File instance."
with pytest.raises(IOError, match=match):
mtch = "Unable to operate on closed File instance."
with pytest.raises(IOError, match=mtch):
f.create_group("group")
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
grp.create_group("group")
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
grp.attrs = {'group': 'attrs'}


Expand All @@ -349,16 +349,16 @@ def test_close_attrs(setup_teardown_file):
file_attrs = f.attrs
f.close()

match = "Unable to operate on closed File instance."
with pytest.raises(IOError, match=match):
mtch = "Unable to operate on closed File instance."
with pytest.raises(IOError, match=mtch):
f.attrs = {'file': 'attrs'}
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
file_attrs['new'] = 'yo'

# unable to retrieve stuff
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
file_attrs['file']
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
f.attrs
assert 'file' not in file_attrs

Expand All @@ -373,12 +373,12 @@ def test_close_raw(setup_teardown_file):
assert "raw" not in f

# unable to create new stuff
match = "Unable to operate on closed File instance."
with pytest.raises(IOError, match=match):
mtch = "Unable to operate on closed File instance."
with pytest.raises(IOError, match=mtch):
f.create_raw('raw')

# unable to retrieve
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
f['raw']


Expand All @@ -396,25 +396,25 @@ def test_close_dataset(setup_teardown_file):
assert 'dataset' not in f

# unable to create new stuff
match = "Unable to operate on closed File instance."
mtch = "Unable to operate on closed File instance."

with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
f.create_dataset('dataset', data=np.array([1,2,3]))
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
grp.create_dataset('dataset', data=np.array([1,2,3]))
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
dset.attrs = {'dataset': 'attrs'}
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
dset_attrs['new'] = 'yo'

# unable to retrieve stuff
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
dset.data
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
dset.shape
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
dset.dtype
with pytest.raises(IOError, match=match):
with pytest.raises(IOError, match=mtch):
dset.attrs

assert 'dataset' not in dset_attrs
Expand Down
16 changes: 8 additions & 8 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def test_nonexisting(setup_teardown_file):
"""Deleting non-existent object raises KeyError."""
f = setup_teardown_file[3]
grp = f.create_group("test")
match = "No such object: 'foo' in path *"
with pytest.raises(KeyError, match=match):
mtch = "No such object: 'foo' in path *"
with pytest.raises(KeyError, match=mtch):
del grp["foo"]


Expand All @@ -231,8 +231,8 @@ def test_readonly_delete_exception(setup_teardown_file):
f.close()

f = File(setup_teardown_file[1], "r")
match = "Cannot change data on file in read only 'r' mode"
with pytest.raises(IOError, match=match):
mtch = "Cannot change data on file in read only 'r' mode"
with pytest.raises(IOError, match=mtch):
del f["foo"]


Expand All @@ -248,8 +248,8 @@ def test_delete_dataset(setup_teardown_file):
del foo
assert 'foo' in grp
del grp['foo']
match = "No such object: 'foo' in path *"
with pytest.raises(KeyError, match=match):
mtch = "No such object: 'foo' in path *"
with pytest.raises(KeyError, match=mtch):
grp['foo']
# the "bar" dataset is intact
assert isinstance(grp['bar'], Dataset)
Expand Down Expand Up @@ -296,8 +296,8 @@ def test_open_deep(setup_teardown_file):
def test_nonexistent(setup_teardown_file):
"""Opening missing objects raises KeyError."""
f = setup_teardown_file[3]
match = "No such object: 'foo' in path *"
with pytest.raises(KeyError, match=match):
mtch = "No such object: 'foo' in path *"
with pytest.raises(KeyError, match=mtch):
f["foo"]


Expand Down

0 comments on commit 7fadf04

Please sign in to comment.