Skip to content

Commit

Permalink
Fix expectedFailure in processing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 4, 2016
1 parent 0395b38 commit 61b8896
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -67,19 +67,7 @@ def test_algorithms(self):
algorithm_tests = yaml.load(stream)

for algtest in algorithm_tests['tests']:
expectFailure = False
if 'expectedFailure' in algtest:
exec('\n'.join(algtest['expectedFailure'][:-1]))
expectFailure = eval(algtest['expectedFailure'][-1])
if expectFailure:
try:
yield self.check_algorithm, algtest['name'], algtest
except Exception:
pass
else:
raise _UnexpectedSuccess
else:
yield self.check_algorithm, algtest['name'], algtest
yield self.check_algorithm, algtest['name'], algtest

def check_algorithm(self, name, defs):
"""
Expand All @@ -101,9 +89,25 @@ def check_algorithm(self, name, defs):
for r, p in defs['results'].iteritems():
alg.setOutputValue(r, self.load_result_param(p))

print(alg.getAsCommand())
self.assertTrue(AlgorithmExecutor.runalg(alg))
self.check_results(alg.getOutputValuesAsDictionary(), defs['results'])
expectFailure = False
if 'expectedFailure' in defs:
exec('\n'.join(defs['expectedFailure'][:-1])) in globals(), locals()
expectFailure = eval(defs['expectedFailure'][-1])

def doCheck():
print(alg.getAsCommand())
self.assertTrue(AlgorithmExecutor.runalg(alg))
self.check_results(alg.getOutputValuesAsDictionary(), defs['results'])

if expectFailure:
try:
doCheck()
except Exception:
pass
else:
raise _UnexpectedSuccess
else:
doCheck()

def load_params(self, params):
"""
Expand Down

0 comments on commit 61b8896

Please sign in to comment.