From 3e5f886296060de8ecdc2f38355fae67a88c08bb Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Thu, 18 Nov 2021 12:06:42 +0100 Subject: [PATCH 1/2] use new paradigm for tests not raising exceptions --- tests/utils/test_analytics_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/utils/test_analytics_utils.py b/tests/utils/test_analytics_utils.py index bbcc407ae03..8fa97ecd1de 100644 --- a/tests/utils/test_analytics_utils.py +++ b/tests/utils/test_analytics_utils.py @@ -13,6 +13,7 @@ # permissions and limitations under the License. import platform +from contextlib import ExitStack as does_not_raise from zenml.constants import VALID_OPERATING_SYSTEMS from zenml.utils.analytics_utils import get_segment_key, get_system_info @@ -20,10 +21,8 @@ def test_get_segment_key(): """Checks the get_segment_key method returns a value""" - try: + with does_not_raise(): get_segment_key() - except Exception as e: - assert False, f"Exception raised: {e}" def test_get_system_info_type(): From 5e50608587ab1c3caba1b014cfeabec3f6c96a21 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Thu, 18 Nov 2021 12:10:05 +0100 Subject: [PATCH 2/2] use new paradigm for tests not raising exceptions --- tests/core/test_repo.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/core/test_repo.py b/tests/core/test_repo.py index a9aff73ddec..b260b2d9a04 100644 --- a/tests/core/test_repo.py +++ b/tests/core/test_repo.py @@ -15,6 +15,7 @@ # TODO: [MEDIUM] add basic CRUD tests back in import os +from contextlib import ExitStack as does_not_raise from pathlib import Path import pytest @@ -52,9 +53,11 @@ def test_initializing_repository_from_root_sets_cwd_as_repo_path() -> None: def test_initializing_repository_without_git_repo_does_not_raise_error( tmp_path: str, ) -> None: - """Check initializing repository without git repository does not raise error""" - repo = Repository(str(tmp_path)) - assert repo.git_wrapper is None + """Check initializing repository without git repository does not raise + error""" + with does_not_raise(): + repo = Repository(str(tmp_path)) + assert repo.git_wrapper is None def test_initializing_repo_with_git_repo_present_sets_git_wrapper(