From 90aba23d7c5fe3fb2a8e0ff4c8d0bfe9eda7e049 Mon Sep 17 00:00:00 2001 From: Catalina Peralta Date: Wed, 19 Oct 2022 14:57:34 -0700 Subject: [PATCH 1/2] add more error cases to skip decorator --- .../azure-ai-formrecognizer/tests/conftest.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py b/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py index 0bf3ca4f0253..a9c423e53f6c 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py @@ -6,16 +6,18 @@ # license information. # -------------------------------------------------------------------------- +import logging import pytest from functools import wraps from azure.core.exceptions import HttpResponseError import sys -from devtools_testutils import add_remove_header_sanitizer, add_general_regex_sanitizer, add_oauth_response_sanitizer, add_body_key_sanitizer, test_proxy - -# Ignore async tests for Python < 3.6 -collect_ignore_glob = [] -if sys.version_info < (3, 6): - collect_ignore_glob.append("*_async.py") +from devtools_testutils import ( + add_remove_header_sanitizer, + add_general_regex_sanitizer, + add_oauth_response_sanitizer, + add_body_key_sanitizer, + test_proxy, +) @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): @@ -67,6 +69,18 @@ def wrapper(*args, **kwargs): try: return f(*args, **kwargs) except HttpResponseError as error: + logger = logging.getLogger("azure") if "Invalid request".casefold() in error.message.casefold(): - pytest.mark.skip("flaky service response") + pytest.mark.skip("flaky service response: {}".format(error)) + logger.debug("flaky service response: {}".format(error)) + elif "Generic error".casefold() in error.message.casefold(): + pytest.mark.skip("flaky service response: {}".format(error)) + logger.debug("flaky service response: {}".format(error)) + elif "Timeout" in error.message.casefold(): + pytest.mark.skip("flaky service response: {}".format(error)) + logger.debug("flaky service response: {}".format(error)) + elif "InvalidRequest" in error.message.casefold(): + pytest.mark.skip("flaky service response: {}".format(error)) + logger.debug("flaky service response: {}".format(error)) + return wrapper From 8ef04d8add4e25b7321f59c7c6155b05c5a7faf6 Mon Sep 17 00:00:00 2001 From: Catalina Peralta Date: Wed, 19 Oct 2022 15:08:18 -0700 Subject: [PATCH 2/2] update last case to catch invalidimage errors --- sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py b/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py index a9c423e53f6c..948404e2d43d 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py @@ -79,7 +79,7 @@ def wrapper(*args, **kwargs): elif "Timeout" in error.message.casefold(): pytest.mark.skip("flaky service response: {}".format(error)) logger.debug("flaky service response: {}".format(error)) - elif "InvalidRequest" in error.message.casefold(): + elif "InvalidImage" in error.message.casefold(): pytest.mark.skip("flaky service response: {}".format(error)) logger.debug("flaky service response: {}".format(error))