summaryrefslogtreecommitdiff
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2023-01-03 15:21:15 -0500
committerNed Batchelder <ned@nedbatchelder.com>2023-01-03 15:29:00 -0500
commit4f3ccf213d813bb57775b2643b8bae5e08cbbbd0 (patch)
treefb113cb24362ee3fd67825867874ce3aa713b55e /tests/helpers.py
parent98301ed240a141592573c2ed239e006d42a26161 (diff)
downloadpython-coveragepy-git-4f3ccf213d813bb57775b2643b8bae5e08cbbbd0.tar.gz
refactor: a better way to have maybe-importable third-party modules
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py20
1 files changed, 0 insertions, 20 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 1645138c..0503097e 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -15,12 +15,10 @@ import subprocess
import textwrap
import warnings
-from types import ModuleType
from typing import (
cast,
Any, Callable, Generator, Iterable, List, Optional, Set, Tuple, Type, Union,
)
-from unittest import mock
import pytest
@@ -284,24 +282,6 @@ def change_dir(new_dir: str) -> Generator[None, None, None]:
os.chdir(old_dir)
-def without_module(using_module: ModuleType, missing_module_name: str) -> mock._patch[Any]:
- """
- Hide a module for testing.
-
- Use this in a test function to make an optional module unavailable during
- the test::
-
- with without_module(product.something, 'tomli'):
- use_toml_somehow()
-
- Arguments:
- using_module: a module in which to hide `missing_module_name`.
- missing_module_name (str): the name of the module to hide.
-
- """
- return mock.patch.object(using_module, missing_module_name, None)
-
-
def assert_count_equal(a: Iterable[Union[int, str]], b: Iterable[Union[int, str]]) -> None:
"""
A pytest-friendly implementation of assertCountEqual.