--- a/dulwich/contrib/test_swift.py +++ b/dulwich/contrib/test_swift.py @@ -58,9 +58,12 @@ except ImportError: missing_libs.append("geventhttpclient") try: - from mock import patch + from unittest.mock import patch except ImportError: - missing_libs.append("mock") + try: + from mock import patch + except ImportError: + missing_libs.append("mock") skipmsg = "Required libraries are not installed (%r)" % missing_libs --- a/dulwich/tests/test_archive.py +++ b/dulwich/tests/test_archive.py @@ -41,9 +41,12 @@ from dulwich.tests.utils import ( ) try: - from mock import patch + from unittest.mock import patch except ImportError: - patch = None # type: ignore + try: + from mock import patch + except ImportError: + patch = None # type: ignore class ArchiveTests(TestCase): --- a/setup.py +++ b/setup.py @@ -62,7 +62,7 @@ tests_require = ['fastimport'] if '__pypy__' not in sys.modules and not sys.platform == 'win32': tests_require.extend([ - 'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1']) + 'gevent', 'geventhttpclient', 'setuptools>=17.1']) ext_modules = [