Skip to content

Commit

Permalink
tests: make compareWkt more tolerant towards whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 28, 2014
1 parent 4a8f627 commit ab10559
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsgeometry.py
Expand Up @@ -911,7 +911,7 @@ def testDeleteVertex(self):
polygon = QgsGeometry.fromWkt("POLYGON((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0))")

assert polygon.deleteVertex(2), "Delete vertex 2 failed"
print "FIXME: exportToWkt doesn't put a blanks behind the comma"
print "FIXME: exportToWkt doesn't put a blank behind the comma"
expwkt = "POLYGON((0 0,1 0,2 1,2 2,0 2,0 0))"
wkt = polygon.exportToWkt()
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
Expand Down
8 changes: 4 additions & 4 deletions tests/src/python/utilities.py
Expand Up @@ -47,7 +47,6 @@
PARENT = None
IFACE = None
GEOCRS = 4326 # constant for EPSG:GEOCRS Geographic CRS id
GOOGLECRS = 900913 # constant for EPSG:GOOGLECRS Google Mercator id

FONTSLOADED = False

Expand Down Expand Up @@ -201,11 +200,12 @@ def writeShape(theMemoryLayer, theFileName):


def compareWkt(a, b, tol=0.000001):
r = re.compile( "-?\d+(?:\.\d+)?(?:[eE]\d+)?" )
r0 = re.compile( "-?\d+(?:\.\d+)?(?:[eE]\d+)?" )
r1 = re.compile( "\s*,\s*" )

# compare the structure
a0 = r.sub( "#", a )
b0 = r.sub( "#", b )
a0 = r1.sub( ",", r0.sub( "#", r ) )

This comment has been minimized.

Copy link
@3nids

3nids Feb 28, 2014

Member

isn't this supposed to be
a0 = r1.sub( ",", r0.sub( "#", a) ) ?

b0 = r1.sub( ",", r0.sub( "#", b ) )
if a0 != b0:
return False

Expand Down

0 comments on commit ab10559

Please sign in to comment.