Skip to content

Commit f8a6995

Browse files
Apply ruff/flake8-pytest-style rule PT012
PT012 `pytest.raises()` block should contain a single simple statement
1 parent 0019733 commit f8a6995

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ extend-select = [
324324
ignore = [
325325
"ANN401",
326326
"PT011", # TODO: apply this rule
327-
"PT012", # TODO: apply this rule
328327
"PT030", # TODO: apply this rule
329328
"PT031", # TODO: apply this rule
330329
"RET505",

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ def test_save_errors() -> None:
259259
with pytest.raises(ValueError):
260260
# no arrays provided
261261
save("data/group.zarr")
262+
a = np.arange(10)
262263
with pytest.raises(TypeError):
263264
# mode is no valid argument and would get handled as an array
264-
a = np.arange(10)
265265
zarr.save("data/example.zarr", a, mode="w")
266266

267267

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ async def write(
141141

142142
_mock.call.assert_called()
143143

144+
config.set({"codec_pipeline.path": "wrong_name"})
144145
with pytest.raises(BadConfigError):
145-
config.set({"codec_pipeline.path": "wrong_name"})
146146
get_pipeline_class()
147147

148148
class MockEnvCodecPipeline(CodecPipeline):

tests/test_group.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,13 @@ def test_group_create_array(
655655

656656
if not overwrite:
657657
if method == "create_array":
658-
with pytest.raises(ContainsArrayError):
658+
with pytest.raises(ContainsArrayError): # noqa: PT012
659659
a = group.create_array(name=name, shape=shape, dtype=dtype)
660660
a[:] = data
661661
elif method == "array":
662-
with pytest.raises(ContainsArrayError), pytest.warns(DeprecationWarning):
663-
a = group.array(name=name, shape=shape, dtype=dtype)
662+
with pytest.raises(ContainsArrayError): # noqa: PT012
663+
with pytest.warns(DeprecationWarning):
664+
a = group.array(name=name, shape=shape, dtype=dtype)
664665
a[:] = data
665666

666667
assert array.path == normalize_path(name)

tests/test_indexing.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,17 +1093,17 @@ def test_get_coordinate_selection_2d(store: StorePath) -> None:
10931093
ix1 = np.array([[1, 3, 2], [1, 0, 0]])
10941094
_test_get_coordinate_selection(a, z, (ix0, ix1))
10951095

1096+
selection = slice(5, 15), [1, 2, 3]
10961097
with pytest.raises(IndexError):
1097-
selection = slice(5, 15), [1, 2, 3]
10981098
z.get_coordinate_selection(selection) # type:ignore[arg-type]
1099+
selection = [1, 2, 3], slice(5, 15)
10991100
with pytest.raises(IndexError):
1100-
selection = [1, 2, 3], slice(5, 15)
11011101
z.get_coordinate_selection(selection) # type:ignore[arg-type]
1102+
selection = Ellipsis, [1, 2, 3]
11021103
with pytest.raises(IndexError):
1103-
selection = Ellipsis, [1, 2, 3]
11041104
z.get_coordinate_selection(selection) # type:ignore[arg-type]
1105+
selection = Ellipsis
11051106
with pytest.raises(IndexError):
1106-
selection = Ellipsis
11071107
z.get_coordinate_selection(selection) # type:ignore[arg-type]
11081108

11091109

@@ -1299,14 +1299,14 @@ def test_get_block_selection_2d(store: StorePath) -> None:
12991299
):
13001300
_test_get_block_selection(a, z, selection, expected_idx)
13011301

1302+
selection = slice(5, 15), [1, 2, 3]
13021303
with pytest.raises(IndexError):
1303-
selection = slice(5, 15), [1, 2, 3]
13041304
z.get_block_selection(selection)
1305+
selection = Ellipsis, [1, 2, 3]
13051306
with pytest.raises(IndexError):
1306-
selection = Ellipsis, [1, 2, 3]
13071307
z.get_block_selection(selection)
1308+
selection = slice(15, 20), slice(None)
13081309
with pytest.raises(IndexError): # out of bounds
1309-
selection = slice(15, 20), slice(None)
13101310
z.get_block_selection(selection)
13111311

13121312

@@ -1360,14 +1360,14 @@ def test_set_block_selection_2d(store: StorePath) -> None:
13601360
):
13611361
_test_set_block_selection(v, a, z, selection, expected_idx)
13621362

1363+
selection = slice(5, 15), [1, 2, 3]
13631364
with pytest.raises(IndexError):
1364-
selection = slice(5, 15), [1, 2, 3]
13651365
z.set_block_selection(selection, 42)
1366+
selection = Ellipsis, [1, 2, 3]
13661367
with pytest.raises(IndexError):
1367-
selection = Ellipsis, [1, 2, 3]
13681368
z.set_block_selection(selection, 42)
1369+
selection = slice(15, 20), slice(None)
13691370
with pytest.raises(IndexError): # out of bounds
1370-
selection = slice(15, 20), slice(None)
13711371
z.set_block_selection(selection, 42)
13721372

13731373

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy