Skip to content

Commit

Permalink
Add a raw parameter to assert methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Sep 28, 2020
1 parent 636942a commit 053ae1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsserver.py
Expand Up @@ -64,7 +64,7 @@ class QgsServerTestBase(unittest.TestCase):
# Set to True in child classes to re-generate reference files for this class
regenerate_reference = False

def assertXMLEqual(self, response, expected, msg=''):
def assertXMLEqual(self, response, expected, msg='', raw=False):
"""Compare XML line by line and sorted attributes"""
response_lines = response.splitlines()
expected_lines = expected.splitlines()
Expand All @@ -80,7 +80,7 @@ def assertXMLEqual(self, response, expected, msg=''):
response_line = response_lines[line_no - 1].strip()
response_line = response_line.replace(b'e+6', br'e+06')
# Compare tag
if re.match(RE_ELEMENT, expected_line):
if re.match(RE_ELEMENT, expected_line) and not raw:
expected_elements = re.findall(RE_ELEMENT, expected_line)
response_elements = re.findall(RE_ELEMENT, response_line)
self.assertEqual(expected_elements[0],
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsserver_wms.py
Expand Up @@ -57,7 +57,7 @@ def wms_request(self, request, extra=None, project='test_project.qgs', version='
header, body = self._execute_request(query_string)
return (header, body, query_string)

def wms_request_compare(self, request, extra=None, reference_file=None, project='test_project.qgs', version='1.3.0', ignoreExtent=False, normalizeJson=False):
def wms_request_compare(self, request, extra=None, reference_file=None, project='test_project.qgs', version='1.3.0', ignoreExtent=False, normalizeJson=False, raw=False):
response_header, response_body, query_string = self.wms_request(request, extra, project, version)
response = response_header + response_body
reference_path = os.path.join(self.testdata_path, (request.lower() if not reference_file else reference_file) + '.txt')
Expand Down Expand Up @@ -85,7 +85,7 @@ def _n(r):
expected = re.sub(RE_STRIP_EXTENTS, b'*****', expected)

msg = "request %s failed.\nQuery: %s\nExpected file: %s\nResponse:\n%s" % (query_string, request, reference_path, response.decode('utf-8'))
self.assertXMLEqual(response, expected, msg=msg)
self.assertXMLEqual(response, expected, msg=msg, raw=raw)


class TestQgsServerWMS(TestQgsServerWMSTestBase):
Expand Down

0 comments on commit 053ae1e

Please sign in to comment.