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: Fixes unnecessary-collection-call (C408) for testsuite #3947

Merged
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
40 changes: 23 additions & 17 deletions python/grass/benchmark/testsuite/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ class TestBenchmarksRun(TestCase):
def test_resolutions(self):
"""Test that resolution tests runs without nprocs and plots to file"""
benchmarks = [
dict(
module=Module("r.univar", map="elevation", stdout_=DEVNULL, run_=False),
label="Standard output",
),
dict(
module=Module(
{
"module": Module(
"r.univar", map="elevation", stdout_=DEVNULL, run_=False
),
"label": "Standard output",
},
{
"module": Module(
"r.univar", map="elevation", flags="g", stdout_=DEVNULL, run_=False
),
label="Standard output",
),
"label": "Standard output",
},
]
resolutions = [300, 200, 100]
results = []
Expand All @@ -67,10 +69,12 @@ def test_single(self):
label = "Standard output"
repeat = 4
benchmarks = [
dict(
module=Module("r.univar", map="elevation", stdout_=DEVNULL, run_=False),
label=label,
)
{
"module": Module(
"r.univar", map="elevation", stdout_=DEVNULL, run_=False
),
"label": label,
}
]
results = []
for benchmark in benchmarks:
Expand All @@ -88,11 +92,13 @@ def test_nprocs(self):
label = "Standard output"
repeat = 4
benchmarks = [
dict(
module=Module("r.univar", map="elevation", stdout_=DEVNULL, run_=False),
label=label,
max_nprocs=4,
)
{
"module": Module(
"r.univar", map="elevation", stdout_=DEVNULL, run_=False
),
"label": label,
"max_nprocs": 4,
}
]
results = []
for benchmark in benchmarks:
Expand Down
14 changes: 7 additions & 7 deletions python/grass/gunittest/testsuite/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ def test_pygrass_module(self):
"""Test syntax with Module and required parameters as module"""
module = Module("r.info", map="elevation", flags="gr", run_=False, finish_=True)
self.assertModuleKeyValue(
module, reference=dict(min=55.58, max=156.33), precision=0.01, sep="="
module, reference={"min": 55.58, "max": 156.33}, precision=0.01, sep="="
)

def test_pygrass_simple_module(self):
"""Test syntax with SimpleModule as module"""
module = SimpleModule("r.info", map="elevation", flags="gr")
self.assertModuleKeyValue(
module, reference=dict(min=55.58, max=156.33), precision=0.01, sep="="
module, reference={"min": 55.58, "max": 156.33}, precision=0.01, sep="="
)

def test_direct_parameters(self):
Expand All @@ -148,7 +148,7 @@ def test_direct_parameters(self):
"r.info",
map="elevation",
flags="gr",
reference=dict(min=55.58, max=156.33),
reference={"min": 55.58, "max": 156.33},
precision=0.01,
sep="=",
)
Expand All @@ -157,8 +157,8 @@ def test_parameters_parameter(self):
"""Test syntax with module parameters in one parameters dictionary"""
self.assertModuleKeyValue(
module="r.info",
parameters=dict(map="elevation", flags="gr"),
reference=dict(min=55.58, max=156.33),
parameters={"map": "elevation", "flags": "gr"},
reference={"min": 55.58, "max": 156.33},
precision=0.01,
sep="=",
)
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_assertRastersNoDifference_mean(self):
actual="elevation",
reference="elevation",
precision=0, # this might need to be increased
statistics=dict(mean=0),
statistics={"mean": 0},
msg="The difference of same maps should have small mean",
)
self.assertRaises(
Expand All @@ -246,7 +246,7 @@ def test_assertRastersNoDifference_mean(self):
actual="elevation",
reference="geology",
precision=1,
statistics=dict(mean=0),
statistics={"mean": 0},
msg="The difference of different maps should have huge mean",
)

Expand Down
68 changes: 34 additions & 34 deletions python/grass/gunittest/testsuite/test_assertions_rast3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ def tearDownClass(cls):
)

def test_assertRaster3dFitsUnivar(self):
reference = dict(
n=1000000,
null_cells=0,
cells=1000000,
min=155,
max=155,
range=0,
mean=155,
mean_of_abs=155,
stddev=0,
variance=0,
coeff_var=0,
sum=155000000,
)
reference = {
"n": 1000000,
"null_cells": 0,
"cells": 1000000,
"min": 155,
"max": 155,
"range": 0,
"mean": 155,
"mean_of_abs": 155,
"stddev": 0,
"variance": 0,
"coeff_var": 0,
"sum": 155000000,
}
self.assertRaster3dFitsUnivar(
self.constant_map, reference=reference, precision=0.000001
)
Expand All @@ -63,30 +63,30 @@ def test_assertRaster3dFitsUnivar(self):
ValueError,
self.assertRaster3dFitsUnivar,
self.constant_map,
reference=dict(a=4, b=5, c=6),
reference={"a": 4, "b": 5, "c": 6},
)
self.assertRaises(
CalledModuleError,
self.assertRaster3dFitsUnivar,
"does_not_exists",
reference=dict(a=4, b=5, c=6),
reference={"a": 4, "b": 5, "c": 6},
)

def test_assertRaster3dFitsInfo(self):
reference = dict(
north=200,
south=100,
east=400,
west=200,
bottom=450,
top=500,
nsres=1,
ewres=1,
tbres=1,
rows=100,
cols=200,
depths=50,
)
reference = {
"north": 200,
"south": 100,
"east": 400,
"west": 200,
"bottom": 450,
"top": 500,
"nsres": 1,
"ewres": 1,
"tbres": 1,
"rows": 100,
"cols": 200,
"depths": 50,
}
self.assertRaster3dFitsInfo(self.constant_map, reference=reference)

reference["north"] = 500
Expand All @@ -100,11 +100,11 @@ def test_assertRaster3dFitsInfo(self):
ValueError,
self.assertRaster3dFitsInfo,
self.constant_map,
reference=dict(a=5),
reference={"a": 5},
)

def test_common_values_info_univar(self):
minmax = dict(min=3, max=350)
minmax = {"min": 3, "max": 350}
self.assertRaster3dFitsUnivar(self.rcd_increasing_map, minmax, precision=0.01)
self.assertRaster3dFitsInfo(self.rcd_increasing_map, minmax, precision=0.01)

Expand Down Expand Up @@ -138,7 +138,7 @@ def test_assertRasters3dNoDifference_mean(self):
actual=self.rcd_increasing_map,
reference=self.rcd_increasing_map,
precision=0, # this might need to be increased
statistics=dict(mean=0),
statistics={"mean": 0},
msg="The difference of same maps should have small mean",
)
self.assertRaises(
Expand All @@ -147,7 +147,7 @@ def test_assertRasters3dNoDifference_mean(self):
actual=self.constant_map,
reference=self.rcd_increasing_map,
precision=1,
statistics=dict(mean=0),
statistics={"mean": 0},
msg="The difference of different maps should have huge mean",
)

Expand Down
48 changes: 24 additions & 24 deletions python/grass/gunittest/testsuite/test_assertions_vect.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@
"""

# v.info schools -t
V_UNIVAR_SCHOOLS_TOPO = dict(
nodes=0,
points=167,
lines=0,
boundaries=0,
centroids=0,
areas=0,
islands=0,
primitives=167,
map3d=0,
)
V_UNIVAR_SCHOOLS_TOPO = {
"nodes": 0,
"points": 167,
"lines": 0,
"boundaries": 0,
"centroids": 0,
"areas": 0,
"islands": 0,
"primitives": 167,
"map3d": 0,
}

# v.info schools -g and rounded
V_UNIVAR_SCHOOLS_REGION = dict(
north=248160,
south=203560,
east=671715,
west=619215,
top=0,
bottom=0,
)
V_UNIVAR_SCHOOLS_REGION = {
"north": 248160,
"south": 203560,
"east": 671715,
"west": 619215,
"top": 0,
"bottom": 0,
}

# v.info schools -g and reduced to minimum
V_UNIVAR_SCHOOLS_EXTENDED = dict(
name="schools",
level=2,
num_dblinks=1,
)
V_UNIVAR_SCHOOLS_EXTENDED = {
"name": "schools",
"level": 2,
"num_dblinks": 1,
}


class TestVectorInfoAssertions(TestCase):
Expand Down
6 changes: 3 additions & 3 deletions python/grass/pygrass/modules/interface/testsuite/test_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class TestFlag(TestCase):
def test_get_bash(self):
"""Test get_bash method"""
flag = Flag(diz=dict(name="a"))
flag = Flag(diz={"name": "a"})
self.assertFalse(flag.value)
self.assertEqual("", flag.get_bash())
flag.special = True
Expand All @@ -25,7 +25,7 @@ def test_get_bash(self):

def test_get_python(self):
"""Test get_python method"""
flag = Flag(diz=dict(name="a"))
flag = Flag(diz={"name": "a"})
self.assertFalse(flag.value)
self.assertEqual("", flag.get_python())
flag.special = True
Expand All @@ -37,7 +37,7 @@ def test_get_python(self):

def test_bool(self):
"""Test magic __bool__ method"""
flag = Flag(diz=dict(name="a"))
flag = Flag(diz={"name": "a"})
flag.value = True
self.assertTrue(True if flag else False)
flag.value = False
Expand Down
Loading
Loading