22"""Rewrite part of test.py in pyproj in the form of unittests."""
33
44import math
5+ import re
56import sys
67import unittest
78
1213class BasicTest (unittest .TestCase ):
1314 def testProj4Version (self ):
1415 awips221 = Proj (proj = "lcc" , R = 6371200 , lat_1 = 50 , lat_2 = 50 , lon_0 = - 107 )
15- # self.assertEqual(awips221.proj_version, 4.9 )
16+ assert re . match ( r"\d+\.\d+" , awips221 . proj_version )
1617
1718 def testInitWithBackupString4 (self ):
1819 # this fails unless backup of to_string(4) is used
1920 pj = Proj (
20- "+proj=merc +a=6378137.0 +b=6378137.0 +nadgrids=@null +lon_0=0.0 +x_0=0.0 +y_0=0.0 +units=m +no_defs"
21+ "+proj=merc +a=6378137.0 +b=6378137.0 +nadgrids=@null "
22+ "+lon_0=0.0 +x_0=0.0 +y_0=0.0 +units=m +no_defs"
2123 )
2224 assert pj .crs .is_valid
2325
2426 def testProjAwips221 (self ):
2527 # AWIPS is Advanced Weather Interactive Processing System
2628 params = {"proj" : "lcc" , "R" : 6371200 , "lat_1" : 50 , "lat_2" : 50 , "lon_0" : - 107 }
27- nx = 349
28- ny = 277
2929 awips221 = Proj (
3030 proj = params ["proj" ],
3131 R = params ["R" ],
@@ -73,27 +73,30 @@ def testProjAwips221(self):
7373
7474 def test_from_dict_with_bool (self ):
7575 # issue #183
76- p_d = {'proj' : 'omerc' ,
77- 'lat_2' : 80.27942 ,
78- 'lat_0' : 62.87671 ,
79- 'lat_1' : 42.751232 ,
80- 'ellps' : 'WGS84' ,
81- 'no_rot' : True ,
82- 'lon_1' : 33.793186 ,
83- 'lon_2' : - 18.374414 }
84- p = Proj (p_d )
85- self .assertTrue ('+no_rot' in p .srs .split ())
86- p_d = {'proj' : 'omerc' ,
87- 'lat_2' : 80.27942 ,
88- 'lat_0' : 62.87671 ,
89- 'lat_1' : 42.751232 ,
90- 'ellps' : 'WGS84' ,
91- 'no_rot' : False ,
92- 'lon_1' : 33.793186 ,
93- 'lon_2' : - 18.374414 }
94- p = Proj (p_d )
95- self .assertFalse ('+no_rot' in p .srs .split ())
96-
76+ p_d = {
77+ "proj" : "omerc" ,
78+ "lat_2" : 80.27942 ,
79+ "lat_0" : 62.87671 ,
80+ "lat_1" : 42.751232 ,
81+ "ellps" : "WGS84" ,
82+ "no_rot" : True ,
83+ "lon_1" : 33.793186 ,
84+ "lon_2" : - 18.374414 ,
85+ }
86+ p = Proj (p_d )
87+ self .assertTrue ("+no_rot" in p .srs .split ())
88+ p_d = {
89+ "proj" : "omerc" ,
90+ "lat_2" : 80.27942 ,
91+ "lat_0" : 62.87671 ,
92+ "lat_1" : 42.751232 ,
93+ "ellps" : "WGS84" ,
94+ "no_rot" : False ,
95+ "lon_1" : 33.793186 ,
96+ "lon_2" : - 18.374414 ,
97+ }
98+ p = Proj (p_d )
99+ self .assertFalse ("+no_rot" in p .srs .split ())
97100
98101
99102class InverseHammerTest (unittest .TestCase ):
@@ -136,7 +139,8 @@ def test_tranform_none_2nd_parmeter(self):
136139
137140class Geod_NoDefs_Issue22_Test (unittest .TestCase ):
138141 # Test for Issue #22, Geod with "+no_defs" in initstring
139- # Before PR #23 merged 2015-10-07, having +no_defs in the initstring would result in a ValueError
142+ # Before PR #23 merged 2015-10-07, having +no_defs in the
143+ # initstring would result in a ValueError
140144 def test_geod_nodefs (self ):
141145 Geod ("+a=6378137 +b=6378137 +no_defs" )
142146
@@ -151,16 +155,19 @@ def test_latlong_typeerror(self):
151155 lon , lat = transform (p , p .to_latlong (), 200000 , 400000 )
152156
153157
154- @unittest .skipIf (sys .version_info < (3 , 4 ), "Python 3.4 or newer required for subTest()" )
158+ @unittest .skipIf (
159+ sys .version_info < (3 , 4 ), "Python 3.4 or newer required for subTest()"
160+ )
155161class ForwardInverseTest (unittest .TestCase ):
156162 def test_fwd_inv (self ):
157163 for pj in pj_list .keys ():
158164 with self .subTest (pj = pj ):
159165 try :
160166 p = Proj (proj = pj )
161167 x , y = p (- 30 , 40 )
162- # note, for proj 4.9.2 or before the inverse projection may be missing
163- # and pyproj 1.9.5.1 or before does not test for this and will
168+ # note, for proj 4.9.2 or before the inverse projection
169+ # may be missing and pyproj 1.9.5.1 or before does not
170+ # test for this and will
164171 # give a segmentation fault at this point:
165172 lon , lat = p (x , y , inverse = True )
166173 except RuntimeError :
@@ -188,7 +195,8 @@ def test_not_shared_memory(self):
188195 self .assertNotEqual (self .g .initstring , self .mercury .initstring )
189196
190197 def test_distances (self ):
191- # note calculated distance was not an issue with #64, but it still a shared memory test
198+ # note calculated distance was not an issue with #64,
199+ # but it still a shared memory test
192200 boston_lat = 42.0 + (15.0 / 60.0 )
193201 boston_lon = - 71.0 - (7.0 / 60.0 )
194202 portland_lat = 45.0 + (31.0 / 60.0 )
0 commit comments