Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Fix all remaining PT flake8-pytest-style issues #4452

Merged
merged 6 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,6 @@ ignore = [
"PLW1641", # eq-without-hash
"PLW2901", # redefined-loop-name
"PLW3201", # bad-dunder-method-name
"PT001", # pytest-fixture-incorrect-parentheses-style
"PT004", # pytest-missing-fixture-name-underscore
"PT006", # pytest-parametrize-names-wrong-type
"PT009", # pytest-unittest-assertion
"PT011", # pytest-raises-too-broad
"PT018", # pytest-composite-assertion
"PT023", # pytest-incorrect-mark-parentheses-style
"PTH100", # os-path-abspath
"PTH101", # os-chmod
"PTH102", # os-mkdir
Expand Down Expand Up @@ -313,12 +306,12 @@ ignore = [
"python/grass/__init__.py" = ["PYI056"]
"python/grass/exp*/tests/grass_script_mapset_session_test.py" = ["SIM117"]
"python/grass/exp*/tests/grass_script_tmp_mapset_session_test.py" = ["SIM117"]
"python/grass/gunittest/case.py" = ["PT009"]
"python/grass/gunittest/loader.py" = ["PYI024"]
"python/grass/gunittest/multireport.py" = ["PYI024"]
"python/grass/gunittest/testsu*/d*/s*/s*/subsub*/t*/test_segfaut.py" = ["B018"]
"python/grass/gunittest/testsuite/test_assertions_rast3d.py" = ["FLY002"]
"python/grass/imaging/images2*.py" = ["SIM115"]
"python/grass/jupyter/tests/reprojection_renderer_test.py" = ["PT013"]
"python/grass/jupyter/testsuite/interactivemap_test.py" = ["PGH004"]
"python/grass/jupyter/testsuite/map_test.py" = ["PGH004"]
"python/grass/pydispatch/signal.py" = ["A005"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def test_create_overwrite(xy_session):
.strip()
.split()
)
assert len(rasters) == 1 and rasters[0] == "a"
assert len(rasters) == 1
assert rasters[0] == "a"
with experimental.MapsetSession(
name, create=True, overwrite=True, env=xy_session.env
) as session:
Expand All @@ -86,7 +87,8 @@ def test_create_overwrite(xy_session):
.strip()
.split()
)
assert len(rasters) == 1 and rasters[0] == "a"
assert len(rasters) == 1
assert rasters[0] == "a"
assert os.path.exists(session_file)


Expand All @@ -103,7 +105,8 @@ def test_ensure(xy_session):
.strip()
.split()
)
assert len(rasters) == 1 and rasters[0] == "a"
assert len(rasters) == 1
assert rasters[0] == "a"
with experimental.MapsetSession(name, ensure=True, env=xy_session.env) as session:
session_mapset = gs.read_command("g.mapset", flags="p", env=session.env).strip()
assert name == session_mapset
Expand All @@ -112,7 +115,8 @@ def test_ensure(xy_session):
.strip()
.split()
)
assert len(rasters) == 1 and rasters[0] == "a"
assert len(rasters) == 1
assert rasters[0] == "a"
gs.run_command("r.mapcalc", expression="b = 1", env=session.env)
rasters = (
gs.read_command("g.list", type="raster", mapset=".", env=session.env)
Expand Down
6 changes: 3 additions & 3 deletions python/grass/jupyter/tests/reprojection_renderer_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test ReprojectionRenderer functions"""

from pathlib import Path
from pytest import approx
import pytest
from grass.jupyter.reprojection_renderer import ReprojectionRenderer


Expand All @@ -21,8 +21,8 @@ def test_render_raster(simple_dataset):
assert Path(filename).exists()
# Test bounding box is correct
# Raster is same extent as region so no need to test bbox for use_region=True
assert bbox[0] == approx([0.00072155, -85.48874388])
assert bbox[1] == approx([0.00000000, -85.48766880])
assert bbox[0] == pytest.approx([0.00072155, -85.48874388])
assert bbox[1] == pytest.approx([0.00000000, -85.48766880])


# render_vector produces json
Expand Down
4 changes: 2 additions & 2 deletions python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def run_grid_module():

@xfail_mp_spawn
@pytest.mark.parametrize(
"width, height, processes",
("width", "height", "processes"),
[
(None, None, max_processes()),
(10, None, max_processes()),
Expand Down Expand Up @@ -249,7 +249,7 @@ def run_grid_module():
@xfail_mp_spawn
@pytest.mark.needs_solo_run
@pytest.mark.parametrize(
"processes, backend",
("processes", "backend"),
[
(1, "RasterRow"),
(9, "RasterRow"),
Expand Down
2 changes: 1 addition & 1 deletion python/grass/script/tests/grass_script_setup_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_init_session_finish(tmp_path):
gs.run_command("g.region", flags="p", env=session.env)
session_file = session.env["GISRC"]
session.finish()
with pytest.raises(ValueError):
with pytest.raises(ValueError): # noqa: PT011
session.finish()
assert not session.active
assert not os.path.exists(session_file)
Expand Down
2 changes: 1 addition & 1 deletion temporal/t.rast.list/tests/t_rast_list_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_yaml(space_time_raster_dataset):

@pytest.mark.needs_solo_run
@pytest.mark.parametrize(
"separator,delimiter", [(None, ","), (",", ","), (";", ";"), ("tab", "\t")]
("separator", "delimiter"), [(None, ","), (",", ","), (";", ";"), ("tab", "\t")]
)
def test_csv(space_time_raster_dataset, separator, delimiter):
"""Check CSV can be parsed with different separators"""
Expand Down
Loading