From 28623deedd1b04e84103a9523bf786814a8f7a07 Mon Sep 17 00:00:00 2001 From: Nishant Bansal Date: Sun, 5 Jan 2025 12:47:10 +0530 Subject: [PATCH] fixes pre-commit issues Signed-off-by: Nishant Bansal --- .../r.describe/testsuite/test_r_describe.py | 336 +++++------------- 1 file changed, 97 insertions(+), 239 deletions(-) diff --git a/raster/r.describe/testsuite/test_r_describe.py b/raster/r.describe/testsuite/test_r_describe.py index d4da8fb93ea..f1fbdf97daf 100644 --- a/raster/r.describe/testsuite/test_r_describe.py +++ b/raster/r.describe/testsuite/test_r_describe.py @@ -22,9 +22,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): """Clean up after tests.""" - cls.runModule( - "g.remove", flags="f", type="raster", name=["map"] - ) + cls.runModule("g.remove", flags="f", type="raster", name=["map"]) cls.del_temp_region() def test_plain_describe(self): @@ -35,23 +33,23 @@ def test_plain_describe(self): result = module.outputs.stdout.strip().splitlines() expected_results = [ - "* -5.000000 thru -4.960784 -4.529412 thru -4.490196 -4.019608 thru -3.980392 ", - "-3.509804 thru -3.470588 -3.039216 thru -3.000000 -2.529412 thru -2.490196 ", - "-2.019608 thru -1.980392 -1.549020 thru -1.509804 -1.039216 thru -1.000000 ", + "* -5.000000 thru -4.960784 -4.529412 thru -4.490196 -4.019608 thru -3.980392 ", + "-3.509804 thru -3.470588 -3.039216 thru -3.000000 -2.529412 thru -2.490196 ", + "-2.019608 thru -1.980392 -1.549020 thru -1.509804 -1.039216 thru -1.000000 ", "-0.529412 thru -0.490196 0.450980 thru 0.490196 0.960784 thru 1.000000 ", - "1.470588 thru 1.509804 1.941176 thru 1.980392 2.450980 thru 2.490196 ", - "2.960784 thru 3.000000 3.431373 thru 3.470588 3.941176 thru 3.980392 ", - "4.450980 thru 4.490196 4.960784 thru 5.000000" + "1.470588 thru 1.509804 1.941176 thru 1.980392 2.450980 thru 2.490196 ", + "2.960784 thru 3.000000 3.431373 thru 3.470588 3.941176 thru 3.980392 ", + "4.450980 thru 4.490196 4.960784 thru 5.000000", ] for i, component in enumerate(result): self.assertEqual( component, expected_results[i], f"Mismatch at line {i + 1}" ) - + def test_plain_describe_with_one_flag(self): """Test r.describe with the plain output format and the -1 flag.""" - module = SimpleModule("r.describe", map="map",flags="1") + module = SimpleModule("r.describe", map="map", flags="1") self.assertModule(module) result = module.outputs.stdout.strip().splitlines() @@ -77,17 +75,17 @@ def test_plain_describe_with_one_flag(self): "3.431373-3.470588", "3.941176-3.980392", "4.450980-4.490196", - "4.960784-5.000000" + "4.960784-5.000000", ] for i, component in enumerate(result): self.assertEqual( component, expected_results[i], f"Mismatch at line {i + 1}" ) - + def test_plain_describe_with_r_flag(self): """Test r.describe with the plain output format and the -r flag.""" - module = SimpleModule("r.describe", map="map",flags="r") + module = SimpleModule("r.describe", map="map", flags="r") self.assertModule(module) result = module.outputs.stdout.strip().splitlines() @@ -98,10 +96,10 @@ def test_plain_describe_with_r_flag(self): self.assertEqual( component, expected_results[i], f"Mismatch at line {i + 1}" ) - + def test_plain_describe_with_i_flag(self): """Test r.describe with the plain output format and the -i flag.""" - module = SimpleModule("r.describe", map="map",flags="i") + module = SimpleModule("r.describe", map="map", flags="i") self.assertModule(module) result = module.outputs.stdout.strip().splitlines() @@ -112,289 +110,149 @@ def test_plain_describe_with_i_flag(self): self.assertEqual( component, expected_results[i], f"Mismatch at line {i + 1}" ) - + def test_plain_describe_with_n_flag(self): """Test r.describe with the plain output format and the -n flag.""" - module = SimpleModule("r.describe", map="map",flags="n") + module = SimpleModule("r.describe", map="map", flags="n") self.assertModule(module) result = module.outputs.stdout.strip().splitlines() expected_results = [ - "-5.000000 thru -4.960784 -4.529412 thru -4.490196 -4.019608 thru -3.980392 ", - "-3.509804 thru -3.470588 -3.039216 thru -3.000000 -2.529412 thru -2.490196 ", - "-2.019608 thru -1.980392 -1.549020 thru -1.509804 -1.039216 thru -1.000000 ", + "-5.000000 thru -4.960784 -4.529412 thru -4.490196 -4.019608 thru -3.980392 ", + "-3.509804 thru -3.470588 -3.039216 thru -3.000000 -2.529412 thru -2.490196 ", + "-2.019608 thru -1.980392 -1.549020 thru -1.509804 -1.039216 thru -1.000000 ", "-0.529412 thru -0.490196 0.450980 thru 0.490196 0.960784 thru 1.000000 ", - "1.470588 thru 1.509804 1.941176 thru 1.980392 2.450980 thru 2.490196 ", - "2.960784 thru 3.000000 3.431373 thru 3.470588 3.941176 thru 3.980392 ", - "4.450980 thru 4.490196 4.960784 thru 5.000000" + "1.470588 thru 1.509804 1.941176 thru 1.980392 2.450980 thru 2.490196 ", + "2.960784 thru 3.000000 3.431373 thru 3.470588 3.941176 thru 3.980392 ", + "4.450980 thru 4.490196 4.960784 thru 5.000000", ] for i, component in enumerate(result): self.assertEqual( component, expected_results[i], f"Mismatch at line {i + 1}" ) - + def test_json_describe(self): """Test r.describe with the json output format.""" - module = SimpleModule("r.describe", map="map",format="json") + module = SimpleModule("r.describe", map="map", format="json") self.assertModule(module) result = json.loads(module.outputs.stdout) expected_results = [ - { - "value": "*" - }, - { - "value": "-5.000000 thru -4.960784" - }, - { - "value": "-4.529412 thru -4.490196" - }, - { - "value": "-4.019608 thru -3.980392" - }, - { - "value": "-3.509804 thru -3.470588" - }, - { - "value": "-3.039216 thru -3.000000" - }, - { - "value": "-2.529412 thru -2.490196" - }, - { - "value": "-2.019608 thru -1.980392" - }, - { - "value": "-1.549020 thru -1.509804" - }, - { - "value": "-1.039216 thru -1.000000" - }, - { - "value": "-0.529412 thru -0.490196" - }, - { - "value": "0.450980 thru 0.490196" - }, - { - "value": "0.960784 thru 1.000000" - }, - { - "value": "1.470588 thru 1.509804" - }, - { - "value": "1.941176 thru 1.980392" - }, - { - "value": "2.450980 thru 2.490196" - }, - { - "value": "2.960784 thru 3.000000" - }, - { - "value": "3.431373 thru 3.470588" - }, - { - "value": "3.941176 thru 3.980392" - }, - { - "value": "4.450980 thru 4.490196" - }, - { - "value": "4.960784 thru 5.000000" - } + {"value": "*"}, + {"value": "-5.000000 thru -4.960784"}, + {"value": "-4.529412 thru -4.490196"}, + {"value": "-4.019608 thru -3.980392"}, + {"value": "-3.509804 thru -3.470588"}, + {"value": "-3.039216 thru -3.000000"}, + {"value": "-2.529412 thru -2.490196"}, + {"value": "-2.019608 thru -1.980392"}, + {"value": "-1.549020 thru -1.509804"}, + {"value": "-1.039216 thru -1.000000"}, + {"value": "-0.529412 thru -0.490196"}, + {"value": "0.450980 thru 0.490196"}, + {"value": "0.960784 thru 1.000000"}, + {"value": "1.470588 thru 1.509804"}, + {"value": "1.941176 thru 1.980392"}, + {"value": "2.450980 thru 2.490196"}, + {"value": "2.960784 thru 3.000000"}, + {"value": "3.431373 thru 3.470588"}, + {"value": "3.941176 thru 3.980392"}, + {"value": "4.450980 thru 4.490196"}, + {"value": "4.960784 thru 5.000000"}, ] self.assertListEqual(expected_results, result) - + def test_json_describe_with_one_flag(self): """Test r.describe with the json output format and the -1 flag.""" - module = SimpleModule("r.describe", map="map",flags="1",format="json") + module = SimpleModule("r.describe", map="map", flags="1", format="json") self.assertModule(module) result = json.loads(module.outputs.stdout) expected_results = [ - { - "value": "*" - }, - { - "value": "-5.000000--4.960784" - }, - { - "value": "-4.529412--4.490196" - }, - { - "value": "-4.019608--3.980392" - }, - { - "value": "-3.509804--3.470588" - }, - { - "value": "-3.039216--3.000000" - }, - { - "value": "-2.529412--2.490196" - }, - { - "value": "-2.019608--1.980392" - }, - { - "value": "-1.549020--1.509804" - }, - { - "value": "-1.039216--1.000000" - }, - { - "value": "-0.529412--0.490196" - }, - { - "value": "0.450980-0.490196" - }, - { - "value": "0.960784-1.000000" - }, - { - "value": "1.470588-1.509804" - }, - { - "value": "1.941176-1.980392" - }, - { - "value": "2.450980-2.490196" - }, - { - "value": "2.960784-3.000000" - }, - { - "value": "3.431373-3.470588" - }, - { - "value": "3.941176-3.980392" - }, - { - "value": "4.450980-4.490196" - }, - { - "value": "4.960784-5.000000" - } + {"value": "*"}, + {"value": "-5.000000--4.960784"}, + {"value": "-4.529412--4.490196"}, + {"value": "-4.019608--3.980392"}, + {"value": "-3.509804--3.470588"}, + {"value": "-3.039216--3.000000"}, + {"value": "-2.529412--2.490196"}, + {"value": "-2.019608--1.980392"}, + {"value": "-1.549020--1.509804"}, + {"value": "-1.039216--1.000000"}, + {"value": "-0.529412--0.490196"}, + {"value": "0.450980-0.490196"}, + {"value": "0.960784-1.000000"}, + {"value": "1.470588-1.509804"}, + {"value": "1.941176-1.980392"}, + {"value": "2.450980-2.490196"}, + {"value": "2.960784-3.000000"}, + {"value": "3.431373-3.470588"}, + {"value": "3.941176-3.980392"}, + {"value": "4.450980-4.490196"}, + {"value": "4.960784-5.000000"}, ] self.assertListEqual(expected_results, result) - + def test_json_describe_with_r_flag(self): """Test r.describe with the json output format and the -r flag.""" - module = SimpleModule("r.describe", map="map",flags="r",format="json") + module = SimpleModule("r.describe", map="map", flags="r", format="json") self.assertModule(module) result = json.loads(module.outputs.stdout) - expected_results = [ - { - "value": "*" - }, - { - "value": "-5.000000 thru 5.000000" - } - ] + expected_results = [{"value": "*"}, {"value": "-5.000000 thru 5.000000"}] self.assertListEqual(expected_results, result) - + def test_json_describe_with_i_flag(self): """Test r.describe with the json output format and the -i flag.""" - module = SimpleModule("r.describe", map="map",flags="i",format="json") + module = SimpleModule("r.describe", map="map", flags="i", format="json") self.assertModule(module) result = json.loads(module.outputs.stdout) - expected_results = [ - { - "value": "*" - }, - { - "value": "-5 thru -1" - }, - { - "value": "1-5" - } - ] + expected_results = [{"value": "*"}, {"value": "-5 thru -1"}, {"value": "1-5"}] self.assertListEqual(expected_results, result) - + def test_json_describe_with_n_flag(self): """Test r.describe with the json output format and the -n flag.""" - module = SimpleModule("r.describe", map="map",flags="n",format="json") + module = SimpleModule("r.describe", map="map", flags="n", format="json") self.assertModule(module) result = json.loads(module.outputs.stdout) expected_results = [ - { - "value": "-5.000000 thru -4.960784" - }, - { - "value": "-4.529412 thru -4.490196" - }, - { - "value": "-4.019608 thru -3.980392" - }, - { - "value": "-3.509804 thru -3.470588" - }, - { - "value": "-3.039216 thru -3.000000" - }, - { - "value": "-2.529412 thru -2.490196" - }, - { - "value": "-2.019608 thru -1.980392" - }, - { - "value": "-1.549020 thru -1.509804" - }, - { - "value": "-1.039216 thru -1.000000" - }, - { - "value": "-0.529412 thru -0.490196" - }, - { - "value": "0.450980 thru 0.490196" - }, - { - "value": "0.960784 thru 1.000000" - }, - { - "value": "1.470588 thru 1.509804" - }, - { - "value": "1.941176 thru 1.980392" - }, - { - "value": "2.450980 thru 2.490196" - }, - { - "value": "2.960784 thru 3.000000" - }, - { - "value": "3.431373 thru 3.470588" - }, - { - "value": "3.941176 thru 3.980392" - }, - { - "value": "4.450980 thru 4.490196" - }, - { - "value": "4.960784 thru 5.000000" - } + {"value": "-5.000000 thru -4.960784"}, + {"value": "-4.529412 thru -4.490196"}, + {"value": "-4.019608 thru -3.980392"}, + {"value": "-3.509804 thru -3.470588"}, + {"value": "-3.039216 thru -3.000000"}, + {"value": "-2.529412 thru -2.490196"}, + {"value": "-2.019608 thru -1.980392"}, + {"value": "-1.549020 thru -1.509804"}, + {"value": "-1.039216 thru -1.000000"}, + {"value": "-0.529412 thru -0.490196"}, + {"value": "0.450980 thru 0.490196"}, + {"value": "0.960784 thru 1.000000"}, + {"value": "1.470588 thru 1.509804"}, + {"value": "1.941176 thru 1.980392"}, + {"value": "2.450980 thru 2.490196"}, + {"value": "2.960784 thru 3.000000"}, + {"value": "3.431373 thru 3.470588"}, + {"value": "3.941176 thru 3.980392"}, + {"value": "4.450980 thru 4.490196"}, + {"value": "4.960784 thru 5.000000"}, ] self.assertListEqual(expected_results, result) + if __name__ == "__main__": test()