Skip to content

Commit

Permalink
Fix escaping errors
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 5, 2020
1 parent 80f5a0b commit d084ad9
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/code_layout/doxygen_parser.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def isOperator(self, member_elem):
""" """
try: try:
name = member_elem.find('name').text name = member_elem.find('name').text
if re.match('^operator\W.*', name): if re.match(r'^operator\W.*', name):
return True return True
except: except:
pass pass
Expand Down
4 changes: 2 additions & 2 deletions tests/code_layout/test_qgsdoccoverage.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def testCoverage(self):
if parser.classes_missing_group: if parser.classes_missing_group:
print("---------------------------------") print("---------------------------------")
print('\n') print('\n')
print((colored('{} classes have been added without Doxygen group tag ("\ingroup"):'.format(len(parser.classes_missing_group)), 'yellow'))) print((colored('{} classes have been added without Doxygen group tag ("\\ingroup"):'.format(len(parser.classes_missing_group)), 'yellow')))
print('') print('')
print((' ' + '\n '.join([colored(cls, 'yellow', attrs=['bold']) for cls in parser.classes_missing_group]))) print((' ' + '\n '.join([colored(cls, 'yellow', attrs=['bold']) for cls in parser.classes_missing_group])))


if parser.classes_missing_version_added: if parser.classes_missing_version_added:
print("---------------------------------") print("---------------------------------")
print('\n') print('\n')
print((colored('{} classes have been added without a version added doxygen note ("\since QGIS x.xx"):'.format(len(parser.classes_missing_version_added)), 'yellow'))) print((colored('{} classes have been added without a version added doxygen note ("\\since QGIS x.xx"):'.format(len(parser.classes_missing_version_added)), 'yellow')))
print('') print('')
print((' ' + '\n '.join([colored(cls, 'yellow', attrs=['bold']) for cls in parser.classes_missing_version_added]))) print((' ' + '\n '.join([colored(cls, 'yellow', attrs=['bold']) for cls in parser.classes_missing_version_added])))


Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_authmanager_oauth2_ows.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def setUpClass(cls):
cls.server = subprocess.Popen([sys.executable, server_path], cls.server = subprocess.Popen([sys.executable, server_path],
env=os.environ, stdout=subprocess.PIPE) env=os.environ, stdout=subprocess.PIPE)
line = cls.server.stdout.readline() line = cls.server.stdout.readline()
cls.port = int(re.findall(b':(\d+)', line)[0]) cls.port = int(re.findall(br':(\d+)', line)[0])
assert cls.port != 0 assert cls.port != 0


# We need a valid port before we setup the oauth configuration # We need a valid port before we setup the oauth configuration
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_authmanager_password_ows.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def setUpClass(cls):
env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE) env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE)


line = cls.server.stdout.readline() line = cls.server.stdout.readline()
cls.port = int(re.findall(b':(\d+)', line)[0]) cls.port = int(re.findall(br':(\d+)', line)[0])
assert cls.port != 0 assert cls.port != 0
# Wait for the server process to start # Wait for the server process to start
assert waitServer('%s://%s:%s' % (cls.protocol, cls.hostname, cls.port)), "Server is not responding! %s://%s:%s" % (cls.protocol, cls.hostname, cls.port) assert waitServer('%s://%s:%s' % (cls.protocol, cls.hostname, cls.port)), "Server is not responding! %s://%s:%s" % (cls.protocol, cls.hostname, cls.port)
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsprocessexecutable.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def testModelRun(self):
# internal binary will match, minus the '.app' # internal binary will match, minus the '.app'
found = False found = False
for app_path in glob.glob(d + '/QGIS*.app'): for app_path in glob.glob(d + '/QGIS*.app'):
m = re.search('/(QGIS(_\d\.\d-dev)?)\.app', app_path) m = re.search(r'/(QGIS(_\d\.\d-dev)?)\.app', app_path)
if m: if m:
QGIS_PROCESS_BIN = app_path + '/Contents/MacOS/' + m.group(1) QGIS_PROCESS_BIN = app_path + '/Contents/MacOS/' + m.group(1)
found = True found = True
Expand Down
6 changes: 3 additions & 3 deletions tests/src/python/test_qgsserver_wfs.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
from test_qgsserver import QgsServerTestBase from test_qgsserver import QgsServerTestBase


# Strip path and content length because path may vary # Strip path and content length because path may vary
RE_STRIP_UNCHECKABLE = b'MAP=[^"]+|Content-Length: \d+|timeStamp="[^"]+"' RE_STRIP_UNCHECKABLE = br'MAP=[^"]+|Content-Length: \d+|timeStamp="[^"]+"'
RE_ATTRIBUTES = b'[^>\s]+=[^>\s]+' RE_ATTRIBUTES = br'[^>\s]+=[^>\s]+'




class TestQgsServerWFS(QgsServerTestBase): class TestQgsServerWFS(QgsServerTestBase):
Expand Down Expand Up @@ -109,7 +109,7 @@ def wfs_getfeature_compare(self, requestid, request):
header, body = self._execute_request(query_string) header, body = self._execute_request(query_string)


if requestid == 'hits': if requestid == 'hits':
body = re.sub(b'timeStamp="\d+-\d+-\d+T\d+:\d+:\d+"', body = re.sub(br'timeStamp="\d+-\d+-\d+T\d+:\d+:\d+"',
b'timeStamp="****-**-**T**:**:**"', body) b'timeStamp="****-**-**T**:**:**"', body)


self.result_compare( self.result_compare(
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsserver_wfst.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def setUpClass(cls):
cls.server = subprocess.Popen([sys.executable, server_path], cls.server = subprocess.Popen([sys.executable, server_path],
env=os.environ, stdout=subprocess.PIPE) env=os.environ, stdout=subprocess.PIPE)
line = cls.server.stdout.readline() line = cls.server.stdout.readline()
cls.port = int(re.findall(b':(\d+)', line)[0]) cls.port = int(re.findall(r':(\d+)', line)[0])
assert cls.port != 0 assert cls.port != 0
# Wait for the server process to start # Wait for the server process to start
assert waitServer('http://127.0.0.1:%s' % cls.port), "Server is not responding!" assert waitServer('http://127.0.0.1:%s' % cls.port), "Server is not responding!"
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsserver_wms_getlegendgraphic.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
from qgis.core import QgsProject from qgis.core import QgsProject


# Strip path and content length because path may vary # Strip path and content length because path may vary
RE_STRIP_UNCHECKABLE = b'MAP=[^"]+|Content-Length: \d+' RE_STRIP_UNCHECKABLE = br'MAP=[^"]+|Content-Length: \d+'
RE_ATTRIBUTES = b'[^>\s]+=[^>\s]+' RE_ATTRIBUTES = br'[^>\s]+=[^>\s]+'




class TestQgsServerWMSGetLegendGraphic(TestQgsServerWMSTestBase): class TestQgsServerWMSGetLegendGraphic(TestQgsServerWMSTestBase):
Expand Down
12 changes: 6 additions & 6 deletions tests/src/python/test_qgsserver_wms_getprint.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from utilities import getExecutablePath, unitTestDataPath from utilities import getExecutablePath, unitTestDataPath


# Strip path and content length because path may vary # Strip path and content length because path may vary
RE_STRIP_UNCHECKABLE = b'MAP=[^"]+|Content-Length: \d+' RE_STRIP_UNCHECKABLE = br'MAP=[^"]+|Content-Length: \d+'
RE_ATTRIBUTES = b'[^>\s]+=[^>\s]+' RE_ATTRIBUTES = br'[^>\s]+=[^>\s]+'




class TestQgsServerWMSGetPrint(QgsServerTestBase): class TestQgsServerWMSGetPrint(QgsServerTestBase):
Expand Down Expand Up @@ -126,16 +126,16 @@ def _pdf_diff_error(self, response, headers, image, max_diff=100, max_size_diff=


with open(os.path.join(tempfile.gettempdir(), image + "_result.pdf"), "rb") as rendered_file: with open(os.path.join(tempfile.gettempdir(), image + "_result.pdf"), "rb") as rendered_file:
if not os.environ.get('ENCODED_OUTPUT'): if not os.environ.get('ENCODED_OUTPUT'):
message = "PDF is wrong\: rendered file %s/%s_result.%s" % (tempfile.gettempdir(), image, 'pdf') message = "PDF is wrong: rendered file %s/%s_result.%s" % (tempfile.gettempdir(), image, 'pdf')
else: else:
encoded_rendered_file = base64.b64encode(rendered_file.read()) encoded_rendered_file = base64.b64encode(rendered_file.read())
message = "PDF is wrong\n%s\File:\necho '%s' | base64 -d >%s/%s_result.%s" % ( message = "PDF is wrong\n%sFile:\necho '%s' | base64 -d >%s/%s_result.%s" % (
report, encoded_rendered_file.strip().decode('utf8'), tempfile.gettempdir(), image, 'pdf' report, encoded_rendered_file.strip().decode('utf8'), tempfile.gettempdir(), image, 'pdf'
) )


with open(os.path.join(tempfile.gettempdir(), image + "_result.png"), "rb") as rendered_file: with open(os.path.join(tempfile.gettempdir(), image + "_result.png"), "rb") as rendered_file:
if not os.environ.get('ENCODED_OUTPUT'): if not os.environ.get('ENCODED_OUTPUT'):
message = "Image is wrong\: rendered file %s/%s_result.%s" % (tempfile.gettempdir(), image, 'png') message = "Image is wrong: rendered file %s/%s_result.%s" % (tempfile.gettempdir(), image, 'png')
else: else:
encoded_rendered_file = base64.b64encode(rendered_file.read()) encoded_rendered_file = base64.b64encode(rendered_file.read())
message = "Image is wrong\n%s\nImage:\necho '%s' | base64 -d >%s/%s_result.%s" % ( message = "Image is wrong\n%s\nImage:\necho '%s' | base64 -d >%s/%s_result.%s" % (
Expand All @@ -146,7 +146,7 @@ def _pdf_diff_error(self, response, headers, image, max_diff=100, max_size_diff=
if os.path.exists(os.path.join(tempfile.gettempdir(), image + "_result_diff.png")): if os.path.exists(os.path.join(tempfile.gettempdir(), image + "_result_diff.png")):
with open(os.path.join(tempfile.gettempdir(), image + "_result_diff.png"), "rb") as diff_file: with open(os.path.join(tempfile.gettempdir(), image + "_result_diff.png"), "rb") as diff_file:
if not os.environ.get('ENCODED_OUTPUT'): if not os.environ.get('ENCODED_OUTPUT'):
message = "Image is wrong\: diff file %s/%s_result_diff.%s" % (tempfile.gettempdir(), image, 'png') message = "Image is wrong: diff file %s/%s_result_diff.%s" % (tempfile.gettempdir(), image, 'png')
else: else:
encoded_diff_file = base64.b64encode(diff_file.read()) encoded_diff_file = base64.b64encode(diff_file.read())
message += "\nDiff:\necho '%s' | base64 -d > %s/%s_result_diff.%s" % ( message += "\nDiff:\necho '%s' | base64 -d > %s/%s_result_diff.%s" % (
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def initProcessing(self):
def unload(self): def unload(self):
pass pass



def classFactory(iface): def classFactory(iface):
# load Test class from file Test # load Test class from file Test
return Test(iface) return Test(iface)

0 comments on commit d084ad9

Please sign in to comment.