diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py index e73fcdb4d9..a4f5adf4d0 100644 --- a/django/contrib/gis/geos/libgeos.py +++ b/django/contrib/gis/geos/libgeos.py @@ -101,8 +101,8 @@ geos_version.argtypes = None 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(?P\d+)\.(?P\d+)\.(?P\d+))(rc(?P\d+))?-CAPI-(?P\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(?P\d+)\.(?P\d+)\.(?P\d+))((rc(?P\d+))|dev)?-CAPI-(?P\d+\.\d+\.\d+)$') def geos_version_info(): """ Returns a dictionary containing the various version metadata parsed from diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index 9b241e6164..a8372b4f69 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -901,7 +901,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # 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 @@ class GEOSTest(unittest.TestCase, TestDataMixin): 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))