From ff637038162380dfae9d291d4cd8469ac1706cd3 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Tue, 15 Oct 2024 09:52:54 +0200 Subject: [PATCH] More CI tests coverage --- argopy/tests/test_utils_decorators.py | 69 +++++++++++++++++++++++++++ argopy/tests/test_utils_monitors.py | 4 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 argopy/tests/test_utils_decorators.py diff --git a/argopy/tests/test_utils_decorators.py b/argopy/tests/test_utils_decorators.py new file mode 100644 index 00000000..ecba7c73 --- /dev/null +++ b/argopy/tests/test_utils_decorators.py @@ -0,0 +1,69 @@ +import pytest +import warnings + +from argopy.utils.decorators import DocInherit, deprecated + + +def test_DocInherit(): + + class Profile(object): + def load(self): + """Dummy""" + pass + + class Float(Profile): + @DocInherit + def load(self): + pass + + assert Float.load.__doc__ == Profile.load.__doc__ + + +def test_deprecated_no_reason(): + + @deprecated + def dummy_fct(): + """Dummy""" + pass + + with pytest.deprecated_call(): + dummy_fct() + + +def test_deprecated_with_a_reason(): + + @deprecated("Because !") + def dummy_fct(): + """Dummy""" + pass + + with pytest.deprecated_call(match="Because"): + dummy_fct() + + + +def test_deprecated_with_a_reason_and_version(): + + @deprecated("Because !", version='12.0') + def dummy_fct(): + """Dummy""" + pass + + with pytest.deprecated_call(match="Deprecated since version"): + dummy_fct() + + +def test_deprecated_ignore_caller(): + + @deprecated("Because !", ignore_caller='caller_to_be_ignored') + def dummy_fct(): + """Dummy""" + pass + + def caller_to_be_ignored(): + dummy_fct() + pass + + with warnings.catch_warnings(): + # warnings.simplefilter("error") + caller_to_be_ignored() diff --git a/argopy/tests/test_utils_monitors.py b/argopy/tests/test_utils_monitors.py index c01a3be0..2b7b12f3 100644 --- a/argopy/tests/test_utils_monitors.py +++ b/argopy/tests/test_utils_monitors.py @@ -24,4 +24,6 @@ def test_fetch_status(): @requires_ipywidgets def test_monitor_status(): - monitor_status() + ms = monitor_status() + assert ms.runner in ['notebook', 'terminal', 'standard', False] + assert isinstance(ms.content, str)