Skip to content

Commit

Permalink
Consistently use unittest.mock in tests
Browse files Browse the repository at this point in the history
 - 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)
  • Loading branch information
hroncok committed Oct 17, 2022
1 parent f07a248 commit c4b5561
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 18 deletions.
1 change: 1 addition & 0 deletions 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`
2 changes: 1 addition & 1 deletion pkg_resources/tests/test_markers.py
@@ -1,4 +1,4 @@
import mock
from unittest import mock

from pkg_resources import evaluate_marker

Expand Down
5 changes: 1 addition & 4 deletions pkg_resources/tests/test_pkg_resources.py
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Expand Up @@ -59,7 +59,6 @@ testing =
pytest-perf

# local
mock
flake8-2020
virtualenv>=13.0.0
wheel
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_bdist_deprecations.py
@@ -1,7 +1,7 @@
"""develop tests
"""
import mock
import sys
from unittest import mock

import pytest

Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_easy_install.py
Expand Up @@ -12,14 +12,14 @@
import distutils.errors
import io
import zipfile
import mock
import time
import re
import subprocess
import pathlib
import warnings
from collections import namedtuple
from pathlib import Path
from unittest import mock

import pytest
from jaraco import path
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_packageindex.py
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions setuptools/tests/test_register.py
Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions setuptools/tests/test_upload.py
Expand Up @@ -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

Expand Down

0 comments on commit c4b5561

Please sign in to comment.