diff options
| author | Miro Hrončok <miro@hroncok.cz> | 2022-10-17 14:03:14 +0200 |
|---|---|---|
| committer | Miro Hrončok <miro@hroncok.cz> | 2022-10-17 14:12:46 +0200 |
| commit | c4b556166f9371d0cbc24d50dab83325aac77a3e (patch) | |
| tree | 3264a1d0e8b38074e19fda97f7223bbd345ed9e6 | |
| parent | f07a248e1e58a76eac5069d8c07bdf81e981587d (diff) | |
| download | python-setuptools-git-c4b556166f9371d0cbc24d50dab83325aac77a3e.tar.gz | |
Consistently use unittest.mock in tests
- Some tests used unittest.mock from the standard library
- Some tests used mock from PyPI
- Some tests tried to import unittest.mock with a fallback to mock
(the import never fails on Python 3.7+, older Pythons are not supported)
| -rw-r--r-- | changelog.d/3638.misc.rst | 1 | ||||
| -rw-r--r-- | pkg_resources/tests/test_markers.py | 2 | ||||
| -rw-r--r-- | pkg_resources/tests/test_pkg_resources.py | 5 | ||||
| -rw-r--r-- | setup.cfg | 1 | ||||
| -rw-r--r-- | setuptools/tests/test_bdist_deprecations.py | 2 | ||||
| -rw-r--r-- | setuptools/tests/test_build_clib.py | 3 | ||||
| -rw-r--r-- | setuptools/tests/test_easy_install.py | 2 | ||||
| -rw-r--r-- | setuptools/tests/test_packageindex.py | 2 | ||||
| -rw-r--r-- | setuptools/tests/test_register.py | 5 | ||||
| -rw-r--r-- | setuptools/tests/test_upload.py | 5 |
10 files changed, 10 insertions, 18 deletions
diff --git a/changelog.d/3638.misc.rst b/changelog.d/3638.misc.rst new file mode 100644 index 00000000..54481ec0 --- /dev/null +++ b/changelog.d/3638.misc.rst @@ -0,0 +1 @@ +Drop a test dependency on the ``mock`` package, always use :external+python:py:mod:`unittest.mock` -- by :user:`hroncok` diff --git a/pkg_resources/tests/test_markers.py b/pkg_resources/tests/test_markers.py index 15a3b499..9306d5b3 100644 --- a/pkg_resources/tests/test_markers.py +++ b/pkg_resources/tests/test_markers.py @@ -1,4 +1,4 @@ -import mock +from unittest import mock from pkg_resources import evaluate_marker diff --git a/pkg_resources/tests/test_pkg_resources.py b/pkg_resources/tests/test_pkg_resources.py index 6518820e..684c9777 100644 --- a/pkg_resources/tests/test_pkg_resources.py +++ b/pkg_resources/tests/test_pkg_resources.py @@ -9,10 +9,7 @@ import stat import distutils.dist import distutils.command.install_egg_info -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pkg_resources import ( DistInfoDistribution, Distribution, EggInfoDistribution, @@ -59,7 +59,6 @@ testing = pytest-perf # local - mock flake8-2020 virtualenv>=13.0.0 wheel diff --git a/setuptools/tests/test_bdist_deprecations.py b/setuptools/tests/test_bdist_deprecations.py index 1a900c67..1b69c418 100644 --- a/setuptools/tests/test_bdist_deprecations.py +++ b/setuptools/tests/test_bdist_deprecations.py @@ -1,7 +1,7 @@ """develop tests """ -import mock import sys +from unittest import mock import pytest diff --git a/setuptools/tests/test_build_clib.py b/setuptools/tests/test_build_clib.py index 48bea2b4..af9e7c6d 100644 --- a/setuptools/tests/test_build_clib.py +++ b/setuptools/tests/test_build_clib.py @@ -1,6 +1,7 @@ +from unittest import mock + import pytest -import mock from distutils.errors import DistutilsSetupError from setuptools.command.build_clib import build_clib from setuptools.dist import Distribution diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index d102e586..bca86066 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -12,7 +12,6 @@ import itertools import distutils.errors import io import zipfile -import mock import time import re import subprocess @@ -20,6 +19,7 @@ import pathlib import warnings from collections import namedtuple from pathlib import Path +from unittest import mock import pytest from jaraco import path diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 8e9435ef..73324aa2 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -5,8 +5,8 @@ import platform import urllib.request import urllib.error import http.client +from unittest import mock -import mock import pytest import setuptools.package_index diff --git a/setuptools/tests/test_register.py b/setuptools/tests/test_register.py index 98605806..ed85e9bb 100644 --- a/setuptools/tests/test_register.py +++ b/setuptools/tests/test_register.py @@ -2,10 +2,7 @@ from setuptools.command.register import register from setuptools.dist import Distribution from setuptools.errors import RemovedCommandError -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import pytest diff --git a/setuptools/tests/test_upload.py b/setuptools/tests/test_upload.py index 7586cb26..4ed59bc2 100644 --- a/setuptools/tests/test_upload.py +++ b/setuptools/tests/test_upload.py @@ -2,10 +2,7 @@ from setuptools.command.upload import upload from setuptools.dist import Distribution from setuptools.errors import RemovedCommandError -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import pytest |
