From 2ba97177e5f589e3faf820b160d12feb7795dcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Pich=C3=A9?= Date: Fri, 27 Oct 2023 10:56:16 -0400 Subject: [PATCH] fix documentation --- coveo-ref/README.md | 20 ++++++++++---------- coveo-ref/coveo_ref/__init__.py | 2 +- coveo-ref/tests_coveo_ref/conftest.py | 8 -------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/coveo-ref/README.md b/coveo-ref/README.md index 944676f1..fd1f911a 100644 --- a/coveo-ref/README.md +++ b/coveo-ref/README.md @@ -19,7 +19,7 @@ tool that can extract the string representation of a python objet. This is what ```python from unittest.mock import patch, MagicMock -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.clients import APIClient @patch(*ref(APIClient._do_request)) @@ -64,7 +64,7 @@ But with `ref`, you specify the context separately: ```python from unittest.mock import patch, MagicMock -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.clients import get_api_client from mymodule.tasks import process @@ -100,7 +100,7 @@ The test: ```python from unittest.mock import patch, MagicMock -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.clients import get_api_client from mymodule.tasks import process @@ -132,7 +132,7 @@ can unpack to `patch.object()`: ```python from unittest.mock import patch -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.clients import APIClient def test() -> None: @@ -155,7 +155,7 @@ For instance, consider this test: ```python from http.client import HTTPResponse from unittest.mock import patch, MagicMock -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.tasks import process @@ -226,7 +226,7 @@ So you _know_ this works globally, because no one will (should?) import the priv ```python from unittest.mock import patch, MagicMock -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.tasks import process from mymodule.clients import _get_api_client @@ -259,7 +259,7 @@ The test, showing 3 different methods that work: ```python from unittest.mock import patch, MagicMock -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.clients import get_api_client from mymodule.tasks import process @@ -296,7 +296,7 @@ Sometimes, the test file _is_ the context. When that happens, just pass `__name_ ```python from unittest.mock import patch -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule.clients import get_api_client, APIClient def _prepare_test() -> APIClient: @@ -377,7 +377,7 @@ class MyClass: ```python from unittest.mock import PropertyMock, patch, MagicMock -from coveo_testing.mocks import ref +from coveo_ref import ref from mymodule import MyClass @@ -406,7 +406,7 @@ For this particular scenario, the workaround is to provide the instance as the c ```python from unittest.mock import patch -from coveo_testing.mocks import ref +from coveo_ref import ref class MyClass: diff --git a/coveo-ref/coveo_ref/__init__.py b/coveo-ref/coveo_ref/__init__.py index 1aa5c130..07b4332a 100644 --- a/coveo-ref/coveo_ref/__init__.py +++ b/coveo-ref/coveo_ref/__init__.py @@ -329,7 +329,7 @@ def ref( refactorable mocks. The idea is to provide the thing to mock as the target, and sometimes, the thing that is being tested - as the context. Refer to `coveo-testing`'s readme to better understand when a context is necessary. + as the context. Refer to `coveo-ref`'s readme to better understand when a context is necessary. For example, pass the `HTTPResponse` class as the target and the `my_module.function_to_test` function as the context, so that `my_module.HTTPResponse` becomes mocked (and not httplib.client.HTTPResponse). diff --git a/coveo-ref/tests_coveo_ref/conftest.py b/coveo-ref/tests_coveo_ref/conftest.py index 5050167a..52a2ae1f 100644 --- a/coveo-ref/tests_coveo_ref/conftest.py +++ b/coveo-ref/tests_coveo_ref/conftest.py @@ -1,9 +1 @@ """pytest bootstrap""" - -from _pytest.config import Config -from coveo_testing.markers import register_markers - - -def pytest_configure(config: Config) -> None: - """This pytest hook is ran once, before collecting tests.""" - register_markers(config)