1
- # pylint: disable=redefined-outer-name
2
1
"""
3
2
Tests text.
4
3
"""
15
14
CITIES_DATA = os .path .join (TEST_DATA_DIR , "cities.txt" )
16
15
17
16
18
- @pytest .fixture (scope = "module" )
19
- def projection ():
17
+ @pytest .fixture (scope = "module" , name = "projection" )
18
+ def fixture_projection ():
20
19
"""
21
20
The projection system.
22
21
"""
23
22
return "x10c"
24
23
25
24
26
- @pytest .fixture (scope = "module" )
27
- def region ():
25
+ @pytest .fixture (scope = "module" , name = "region" )
26
+ def fixture_region ():
28
27
"""
29
28
The data region.
30
29
"""
@@ -124,15 +123,25 @@ def test_text_position(region):
124
123
return fig
125
124
126
125
127
- def test_text_xy_with_position_fails (region ):
126
+ def test_text_invalid_inputs (region ):
128
127
"""
129
- Run text by providing both x/y pairs and position arguments .
128
+ Run text by providing invalid combinations of inputs .
130
129
"""
131
130
fig = Figure ()
132
131
with pytest .raises (GMTInvalidInput ):
133
132
fig .text (
134
133
region = region , projection = "x1c" , x = 1.2 , y = 2.4 , position = "MC" , text = "text"
135
134
)
135
+ with pytest .raises (GMTInvalidInput ):
136
+ fig .text (region = region , projection = "x1c" , textfiles = "file.txt" , text = "text" )
137
+ with pytest .raises (GMTInvalidInput ):
138
+ fig .text (region = region , projection = "x1c" , position = "MC" , text = None )
139
+ with pytest .raises (GMTInvalidInput ):
140
+ fig .text (
141
+ region = region , projection = "x1c" , position = "MC" , text = ["text1" , "text2" ]
142
+ )
143
+ with pytest .raises (GMTInvalidInput ):
144
+ fig .text (region = region , projection = "x1c" , textfiles = "file.txt" , x = 1.2 , y = 2.4 )
136
145
137
146
138
147
@pytest .mark .mpl_image_compare
@@ -313,10 +322,8 @@ def test_text_transparency():
313
322
text = [f"TEXT-{ i } -{ j } " for i , j in zip (x , y )]
314
323
315
324
fig = Figure ()
316
-
317
325
fig .basemap (region = [0 , 10 , 10 , 20 ], projection = "X10c" , frame = True )
318
326
fig .text (x = x , y = y , text = text , transparency = 50 )
319
-
320
327
return fig
321
328
322
329
@@ -333,7 +340,6 @@ def test_text_varying_transparency():
333
340
fig = Figure ()
334
341
fig .basemap (region = [0 , 10 , 10 , 20 ], projection = "X10c" , frame = True )
335
342
fig .text (x = x , y = y , text = text , transparency = transparency )
336
-
337
343
return fig
338
344
339
345
@@ -357,7 +363,6 @@ def test_text_nonstr_text():
357
363
Input text is in non-string type (e.g., int, float)
358
364
"""
359
365
fig = Figure ()
360
-
361
366
fig .text (
362
367
region = [0 , 10 , 0 , 10 ],
363
368
projection = "X10c" ,
@@ -366,5 +371,4 @@ def test_text_nonstr_text():
366
371
y = [1 , 2 , 3 , 4 ],
367
372
text = [1 , 2 , 3.0 , 4.0 ],
368
373
)
369
-
370
374
return fig
0 commit comments