Skip to content

Commit ffbca79

Browse files
committed
Added catch support for yaml tests, dummy for now
1 parent 1ce8c07 commit ffbca79

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test_elasticsearch/test_server/test_common.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def run_code(self, test):
4040

4141
def run_do(self, action):
4242
""" Perform an api call with given parameters. """
43+
44+
catch = action.pop('catch', None)
4345
self.assertEquals(1, len(action))
4446

4547
method, args = list(action.items())[0]
@@ -56,12 +58,23 @@ def run_do(self, action):
5658
if k in args:
5759
args[PARAMS_RENAMES[k]] = args.pop(k)
5860

59-
self.last_response = api(**args)
61+
try:
62+
self.last_response = api(**args)
63+
except:
64+
if not catch:
65+
raise
66+
self.run_catch(catch)
67+
else:
68+
if catch:
69+
raise AssertionError('Failed to catch %r in %r.' % (catch, self.last_response))
70+
71+
def run_catch(self, catch):
72+
pass
6073

6174
def run_length(self, action):
6275
self.run_is(action, len)
6376

64-
def run_is(self, action, transform=None):
77+
def run_match(self, action, transform=None):
6578
""" Match part of last response to test data. """
6679

6780
# matching part of the reponse dict

0 commit comments

Comments
 (0)