Skip to content
Permalink
Browse files

Add a raw parameter to assert methods

  • Loading branch information
pblottiere committed Sep 28, 2020
1 parent 636942a commit 053ae1edb5886134b69a4d52ed7a845aea5efb8f
Showing with 4 additions and 4 deletions.
  1. +2 −2 tests/src/python/test_qgsserver.py
  2. +2 −2 tests/src/python/test_qgsserver_wms.py
@@ -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()
@@ -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],
@@ -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')
@@ -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):

0 comments on commit 053ae1e

Please sign in to comment.
You can’t perform that action at this time.