Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #17212 -- Made GEOS version regular expression more robust. Tha…

…nks, strk.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17682 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 771fce45b40deec44b47014829c1f7e973fc7fd7 1 parent bf1112d
@jbronn jbronn authored
View
4 django/contrib/gis/geos/libgeos.py
@@ -101,8 +101,8 @@ def get_pointer_arr(n):
geos_version.restype = c_char_p
# 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'
-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+)$')
+# '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+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)$')
def geos_version_info():
"""
Returns a dictionary containing the various version metadata parsed from
View
14 django/contrib/gis/geos/tests/test_geos.py
@@ -901,7 +901,7 @@ def test23_transform_nosrid(self):
# Keeping line-noise down by only printing the relevant
# warnings once.
warnings.simplefilter('once', UserWarning)
- warnings.simplefilter('once', FutureWarning)
+ warnings.simplefilter('once', FutureWarning)
g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
g.transform(2774)
@@ -1049,6 +1049,18 @@ def test27_valid_reason(self):
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():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(GEOSTest))
Please sign in to comment.
Something went wrong with that request. Please try again.