From 447a568cc351f7883070272b0cce0454dc1c8079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 17 Oct 2022 14:03:14 +0200 Subject: [PATCH] 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) --- pkg_resources/tests/test_markers.py | 2 +- pkg_resources/tests/test_pkg_resources.py | 5 +---- setup.cfg | 1 - setuptools/tests/test_bdist_deprecations.py | 2 +- setuptools/tests/test_build_clib.py | 3 ++- setuptools/tests/test_easy_install.py | 2 +- setuptools/tests/test_packageindex.py | 2 +- setuptools/tests/test_register.py | 5 +---- setuptools/tests/test_upload.py | 5 +---- 9 files changed, 9 insertions(+), 18 deletions(-) diff --git a/pkg_resources/tests/test_markers.py b/pkg_resources/tests/test_markers.py index 15a3b499a60..9306d5b3483 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 6518820e6f3..684c977771c 100644 --- a/pkg_resources/tests/test_pkg_resources.py +++ b/pkg_resources/tests/test_pkg_resources.py @@ -9,10 +9,7 @@ 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, diff --git a/setup.cfg b/setup.cfg index 201c2602478..6921de867f4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 1a900c6766b..1b69c41858f 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 48bea2b43d0..af9e7c6dc39 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 d102e586b46..bca86066adb 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -12,7 +12,6 @@ import distutils.errors import io import zipfile -import mock import time import re import subprocess @@ -20,6 +19,7 @@ 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 8e9435efef0..73324aa271a 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -5,8 +5,8 @@ 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 986058067be..ed85e9bbd3d 100644 --- a/setuptools/tests/test_register.py +++ b/setuptools/tests/test_register.py @@ -2,10 +2,7 @@ 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 7586cb262d4..4ed59bc24d4 100644 --- a/setuptools/tests/test_upload.py +++ b/setuptools/tests/test_upload.py @@ -2,10 +2,7 @@ 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