File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -240,12 +240,7 @@ def test_print_output_plain(self):
240240 mapset = "PERMANENT" ,
241241 input = self .input ,
242242 flags = "p" ,
243- )
244-
245- # Replacing '\r' because Windows uses '\r\n' for line endings, but we
246- # want to remove the '\r' (carriage return) to standardize line endings
247- result = result .replace ("\r " , "" )
248- result_lines = [line for line in result .split ("\n " ) if line .strip () != "" ]
243+ ).splitlines ()
249244
250245 expected = [
251246 "Source cols: 1500" ,
@@ -256,7 +251,7 @@ def test_print_output_plain(self):
256251 "Local east: 78:36:29.891436W" ,
257252 ]
258253
259- self .assertListEqual (result_lines , expected , "Mismatch in print output (plain)" )
254+ self .assertListEqual (result , expected , "Mismatch in print output (plain)" )
260255
261256 def test_print_output_json (self ):
262257 """Test printing input map bounds in the current projection (JSON format)."""
Original file line number Diff line number Diff line change 1+ from grass .gunittest .case import TestCase
2+ from grass .gunittest .gmodules import SimpleModule
3+
4+
5+ class TestRWhatColor (TestCase ):
6+ input = "elevation"
7+ value = "50\n 100\n 116.029\n 135\n 156\n bogus"
8+
9+ @classmethod
10+ def setUpClass (cls ):
11+ cls .use_temp_region ()
12+ cls .runModule ("g.region" , raster = cls .input , flags = "p" )
13+
14+ @classmethod
15+ def tearDownClass (cls ):
16+ cls .del_temp_region ()
17+
18+ def test_r_what_color_plain (self ):
19+ """Test r.what.color command for plain output format."""
20+ module = SimpleModule (
21+ "r.what.color" , input = self .input , flags = "i" , stdin = self .value
22+ )
23+ self .assertModule (module )
24+ result = module .outputs .stdout .splitlines ()
25+ expected = [
26+ "50: *" ,
27+ "100: 255:229:0" ,
28+ "116.029: 255:128:0" ,
29+ "135: 195:127:59" ,
30+ "156: 23:22:21" ,
31+ "*: *" ,
32+ ]
33+
34+ self .assertListEqual (result , expected , "Mismatch in printed output (plain)" )
35+
36+ def test_r_what_color_plain_with_format_option (self ):
37+ """Test the r.what.color command with the format option for plain text output."""
38+ module = SimpleModule (
39+ "r.what.color" ,
40+ input = self .input ,
41+ flags = "i" ,
42+ stdin = self .value ,
43+ format = "#%02X%02X%02X" ,
44+ )
45+ self .assertModule (module )
46+ result = module .outputs .stdout .splitlines ()
47+ expected = [
48+ "50: *" ,
49+ "100: #FFE500" ,
50+ "116.029: #FF8000" ,
51+ "135: #C37F3B" ,
52+ "156: #171615" ,
53+ "*: *" ,
54+ ]
55+
56+ self .assertListEqual (
57+ result ,
58+ expected ,
59+ "Mismatch in printed output (plain) with the format option" ,
60+ )
61+
62+
63+ if __name__ == "__main__" :
64+ from grass .gunittest .main import test
65+
66+ test ()
You can’t perform that action at this time.
0 commit comments