Skip to content

Commit aefc942

Browse files
committed
Implemented the matching by regex feature for the yaml test suite
1 parent cfcf062 commit aefc942

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test_elasticsearch/test_server/test_common.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828

2929
# test features we have implemented
30-
IMPLEMENTED_FEATURES = ()
30+
IMPLEMENTED_FEATURES = ('regex')
3131

3232
class InvalidActionType(Exception):
3333
pass
@@ -46,11 +46,15 @@ def _resolve(self, value):
4646
value = value[1:]
4747
self.assertIn(value, self._state)
4848
value = self._state[value]
49+
if isinstance(value, (type(u''), type(''))):
50+
value = value.strip()
4951
return value
5052

5153
def _lookup(self, path):
5254
# fetch the possibly nested value from last_response
5355
value = self.last_response
56+
if path == '$body':
57+
return value
5458
path = path.replace(r'\.', '\1')
5559
for step in path.split('.'):
5660
if not step:
@@ -167,7 +171,12 @@ def run_match(self, action):
167171
for path, expected in action.items():
168172
value = self._lookup(path)
169173
expected = self._resolve(expected)
170-
self.assertEquals(expected, value)
174+
175+
if expected.startswith('/') and expected.endswith('/'):
176+
expected = re.compile(expected[1:-1], re.VERBOSE)
177+
self.assertTrue(expected.search(value))
178+
else:
179+
self.assertEquals(expected, value)
171180

172181

173182
def construct_case(filename, name):

0 commit comments

Comments
 (0)