From c05027868e736d89dd1e4064b39e477eb2f87aee Mon Sep 17 00:00:00 2001 From: jo Date: Wed, 12 Jul 2023 22:24:20 +0200 Subject: [PATCH 1/2] feat: move hcloud.hcloud module to hcloud._client --- hcloud/__init__.py | 2 +- hcloud/{hcloud.py => _client.py} | 0 tests/unit/conftest.py | 2 +- tests/unit/{test_hcloud.py => test_client.py} | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename hcloud/{hcloud.py => _client.py} (100%) rename tests/unit/{test_hcloud.py => test_client.py} (100%) diff --git a/hcloud/__init__.py b/hcloud/__init__.py index 592ff64d..5beda91d 100644 --- a/hcloud/__init__.py +++ b/hcloud/__init__.py @@ -1,2 +1,2 @@ +from ._client import Client # noqa from ._exceptions import APIException, HCloudException # noqa -from .hcloud import Client # noqa diff --git a/hcloud/hcloud.py b/hcloud/_client.py similarity index 100% rename from hcloud/hcloud.py rename to hcloud/_client.py diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index d15d36b5..0ab74906 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -7,7 +7,7 @@ @pytest.fixture(autouse=True, scope="function") def mocked_requests(): - patcher = mock.patch("hcloud.hcloud.requests") + patcher = mock.patch("hcloud._client.requests") mocked_requests = patcher.start() yield mocked_requests patcher.stop() diff --git a/tests/unit/test_hcloud.py b/tests/unit/test_client.py similarity index 100% rename from tests/unit/test_hcloud.py rename to tests/unit/test_client.py From 516c0619f7e6661d087c8979f577aa39d5e673c2 Mon Sep 17 00:00:00 2001 From: jo Date: Wed, 12 Jul 2023 22:35:28 +0200 Subject: [PATCH 2/2] feat: add deprecation for hcloud.hcloud module --- hcloud/hcloud.py | 9 +++++++++ tests/unit/test_hcloud.py | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 hcloud/hcloud.py create mode 100644 tests/unit/test_hcloud.py diff --git a/hcloud/hcloud.py b/hcloud/hcloud.py new file mode 100644 index 00000000..af4e5c2a --- /dev/null +++ b/hcloud/hcloud.py @@ -0,0 +1,9 @@ +import warnings + +warnings.warn( + "The 'hcloud.hcloud' module is deprecated, please import from the 'hcloud' module instead (e.g. 'from hcloud import Client').", + DeprecationWarning, + stacklevel=2, +) + +from ._client import * # noqa diff --git a/tests/unit/test_hcloud.py b/tests/unit/test_hcloud.py new file mode 100644 index 00000000..87ab50aa --- /dev/null +++ b/tests/unit/test_hcloud.py @@ -0,0 +1,6 @@ +import pytest + + +def test_deprecated_hcloud_hcloud_module(): + with pytest.deprecated_call(): + from hcloud.hcloud import Client # noqa