Fixed #17212 -- Made GEOS version regular expression more robust. Thanks, strk.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17682 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bf1112de7d
commit
771fce45b4
|
@ -101,8 +101,8 @@ geos_version.argtypes = None
|
||||||
geos_version.restype = c_char_p
|
geos_version.restype = c_char_p
|
||||||
|
|
||||||
# Regular expression should be able to parse version strings such as
|
# Regular expression should be able to parse version strings such as
|
||||||
# '3.0.0rc4-CAPI-1.3.3', or '3.0.0-CAPI-1.4.1'
|
# '3.0.0rc4-CAPI-1.3.3', '3.0.0-CAPI-1.4.1' or '3.4.0dev-CAPI-1.8.0'
|
||||||
version_regex = re.compile(r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))(rc(?P<release_candidate>\d+))?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)$')
|
version_regex = re.compile(r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)$')
|
||||||
def geos_version_info():
|
def geos_version_info():
|
||||||
"""
|
"""
|
||||||
Returns a dictionary containing the various version metadata parsed from
|
Returns a dictionary containing the various version metadata parsed from
|
||||||
|
|
|
@ -901,7 +901,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
# Keeping line-noise down by only printing the relevant
|
# Keeping line-noise down by only printing the relevant
|
||||||
# warnings once.
|
# warnings once.
|
||||||
warnings.simplefilter('once', UserWarning)
|
warnings.simplefilter('once', UserWarning)
|
||||||
warnings.simplefilter('once', FutureWarning)
|
warnings.simplefilter('once', FutureWarning)
|
||||||
|
|
||||||
g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
|
g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
|
||||||
g.transform(2774)
|
g.transform(2774)
|
||||||
|
@ -1049,6 +1049,18 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||||
|
|
||||||
print "\nEND - expecting GEOS_NOTICE; safe to ignore.\n"
|
print "\nEND - expecting GEOS_NOTICE; safe to ignore.\n"
|
||||||
|
|
||||||
|
def test28_geos_version(self):
|
||||||
|
"Testing the GEOS version regular expression."
|
||||||
|
from django.contrib.gis.geos.libgeos import version_regex
|
||||||
|
versions = [ ('3.0.0rc4-CAPI-1.3.3', '3.0.0'),
|
||||||
|
('3.0.0-CAPI-1.4.1', '3.0.0'),
|
||||||
|
('3.4.0dev-CAPI-1.8.0', '3.4.0') ]
|
||||||
|
for v, expected in versions:
|
||||||
|
m = version_regex.match(v)
|
||||||
|
self.assertTrue(m)
|
||||||
|
self.assertEqual(m.group('version'), expected)
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
s = unittest.TestSuite()
|
s = unittest.TestSuite()
|
||||||
s.addTest(unittest.makeSuite(GEOSTest))
|
s.addTest(unittest.makeSuite(GEOSTest))
|
||||||
|
|
Loading…
Reference in New Issue