From aaeab13f8b4c09a4773dc2a305164ecc268f9bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Fri, 3 Jan 2014 18:05:25 +0100 Subject: [PATCH] Handle regexp-based catch statements in the yaml test suite --- test_elasticsearch/test_server/test_common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test_elasticsearch/test_server/test_common.py b/test_elasticsearch/test_server/test_common.py index 7435a574..b8f47f05 100644 --- a/test_elasticsearch/test_server/test_common.py +++ b/test_elasticsearch/test_server/test_common.py @@ -3,6 +3,7 @@ Dynamically generated set of TestCases based on set of yaml files decribing some integration tests. These files are shared among all official Elasticsearch clients. """ +import re from os import walk, environ from os.path import exists, join, dirname, pardir import yaml @@ -114,11 +115,12 @@ class YamlTestCase(ElasticTestCase): if min_version <= self.es_version <= max_version: raise SkipTest(reason) - def run_catch(self, catch, exception): self.assertIsInstance(exception, TransportError) if catch in CATCH_CODES: self.assertEquals(CATCH_CODES[catch], exception.status_code) + elif catch[0] == '/' and catch[-1] == '/': + self.assertTrue(re.search(catch[1:-1], exception.error)) def run_gt(self, action): for key, value in action.items():