Skip to content

Commit

Permalink
Revert "Use assertRaises for cleaner code."
Browse files Browse the repository at this point in the history
This reverts commit bcf71e0.
  • Loading branch information
elpaso committed Jun 5, 2020
1 parent 007bf98 commit e499e99
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/src/python/test_qgsserver_wfs.py
Expand Up @@ -189,7 +189,7 @@ def test_wfs_getcapabilities_100_url(self):
self.assertEqual(
"onlineResource=\"my_wfs_advertised_url\"" in item, True)

def result_compare(self, file_name, error_msg_header, header, body):
def result_compare(self, file_name, error_msg_header, header, body, expectEqual=True):
self.assert_headers(header, body)
response = header + body
reference_path = self.testdata_path + file_name
Expand All @@ -202,7 +202,11 @@ def result_compare(self, file_name, error_msg_header, header, body):
self.assertXMLEqual(response, expected, msg="%s\n" %
(error_msg_header))

def wfs_getfeature_post_compare(self, requestid, request):
# If do not expect equal and pass the line above, should throw and assertion error.
if not expectEqual:
self.assertFalse(True, msg='It should get different result for %s.' % error_msg_header)

def wfs_getfeature_post_compare(self, requestid, request, expectEqual=True):
project = self.testdata_path + "test_project_wfs.qgs"
assert os.path.exists(project), "Project file not found: " + project

Expand All @@ -214,7 +218,8 @@ def wfs_getfeature_post_compare(self, requestid, request):
'wfs_getfeature_{}.txt'.format(requestid),
"GetFeature in POST for '{}' failed.".format(requestid),
header,
body
body,
expectEqual
)

def test_getfeature_post(self):
Expand Down Expand Up @@ -476,9 +481,7 @@ def test_getfeature_post(self):
tests.append(('nobbox_post', template.format("")))

for id, req in expectNotEqualTests:
errorMsg = 'Expect different XML response for %s' % id
with self.assertRaises(AssertionError, msg=errorMsg):
self.wfs_getfeature_post_compare(id, req)
self.wfs_getfeature_post_compare(id, req, expectEqual=False)

for id, req in tests:
self.wfs_getfeature_post_compare(id, req)
Expand Down

0 comments on commit e499e99

Please sign in to comment.