Skip to content

Commit 45afaf3

Browse files
authored
Add support for 'allowed_warnings' feature
1 parent 3ca05b9 commit 45afaf3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test_elasticsearch/test_server/test_rest_api_spec.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"catch_unauthorized",
3535
"default_shards",
3636
"warnings",
37+
"allowed_warnings",
3738
}
3839

3940
# broken YAML tests on some releases
@@ -150,6 +151,7 @@ def run_do(self, action):
150151
headers = action.pop("headers", None)
151152
catch = action.pop("catch", None)
152153
warn = action.pop("warnings", ())
154+
allowed_warnings = action.pop("allowed_warnings", ())
153155
assert len(action) == 1
154156

155157
method, args = list(action.items())[0]
@@ -189,11 +191,12 @@ def run_do(self, action):
189191
str(w.message)
190192
for w in caught_warnings
191193
if w.category == ElasticsearchDeprecationWarning
194+
and str(w.message) not in allowed_warnings
192195
]
193196

194197
# Sorting removes the issue with order raised. We only care about
195198
# if all warnings are raised in the single API call.
196-
if sorted(warn) != sorted(caught_warnings):
199+
if warn and sorted(warn) != sorted(caught_warnings):
197200
raise AssertionError(
198201
"Expected warnings not equal to actual warnings: expected=%r actual=%r"
199202
% (warn, caught_warnings)

0 commit comments

Comments
 (0)