diff --git a/setup.py b/setup.py index 79c466321..eccceebb3 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,6 @@ extras_require = { 'colorama>=0.3.5', ], 'test': [ - 'mock', 'pytest', 'pytest-cov', 'html5lib', diff --git a/tests/test_build.py b/tests/test_build.py index 8072906a2..fa620d352 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -10,8 +10,8 @@ import sys from textwrap import dedent +from unittest import mock -import mock import pytest from docutils import nodes diff --git a/tests/test_config.py b/tests/test_config.py index fadf7d6c4..a5da0d6ec 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -8,7 +8,9 @@ :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ -import mock + +from unittest import mock + import pytest import sphinx @@ -257,7 +259,7 @@ def test_conf_warning_message(logger, name, default, annotation, actual, message config.add(name, default, False, annotation or ()) config.init_values() check_confval_types(None, config) - logger.warning.assert_called() + assert logger.warning.called assert logger.warning.call_args[0][0] == message @@ -276,7 +278,7 @@ def test_check_enum_failed(logger): config.add('value', 'default', False, ENUM('default', 'one', 'two')) config.init_values() check_confval_types(None, config) - logger.warning.assert_called() + assert logger.warning.called @mock.patch("sphinx.config.logger") @@ -294,4 +296,4 @@ def test_check_enum_for_list_failed(logger): config.add('value', 'default', False, ENUM('default', 'one', 'two')) config.init_values() check_confval_types(None, config) - logger.warning.assert_called() + assert logger.warning.called diff --git a/tests/test_domain_js.py b/tests/test_domain_js.py index 174a431bf..613623ee5 100644 --- a/tests/test_domain_js.py +++ b/tests/test_domain_js.py @@ -8,9 +8,10 @@ :license: BSD, see LICENSE for details. """ +from unittest.mock import Mock + import pytest from docutils import nodes -from mock import Mock from sphinx import addnodes from sphinx.domains.javascript import JavaScriptDomain diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index ff6387101..c4a50b742 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -8,9 +8,10 @@ :license: BSD, see LICENSE for details. """ +from unittest.mock import Mock + import pytest from docutils import nodes -from mock import Mock from sphinx import addnodes from sphinx.domains.python import py_sig_re, _pseudo_parse_arglist, PythonDomain diff --git a/tests/test_domain_std.py b/tests/test_domain_std.py index dda8a4313..15daeeea6 100644 --- a/tests/test_domain_std.py +++ b/tests/test_domain_std.py @@ -8,7 +8,8 @@ :license: BSD, see LICENSE for details. """ -import mock +from unittest import mock + from docutils import nodes from sphinx.domains.std import StandardDomain diff --git a/tests/test_environment_indexentries.py b/tests/test_environment_indexentries.py index 4475fb273..62e4ffb79 100644 --- a/tests/test_environment_indexentries.py +++ b/tests/test_environment_indexentries.py @@ -9,8 +9,7 @@ """ from collections import namedtuple - -import mock +from unittest import mock from sphinx import locale from sphinx.environment.adapters.indexentries import IndexEntries diff --git a/tests/test_ext_autosummary.py b/tests/test_ext_autosummary.py index 63026beb5..3cc9710d8 100644 --- a/tests/test_ext_autosummary.py +++ b/tests/test_ext_autosummary.py @@ -10,11 +10,13 @@ import sys from io import StringIO +from unittest.mock import Mock import pytest from sphinx.ext.autosummary import mangle_signature, import_by_name, extract_summary from sphinx.testing.util import etree_parse +from sphinx.util.docutils import new_document html_warnfile = StringIO() @@ -57,8 +59,6 @@ def test_mangle_signature(): def test_extract_summary(capsys): - from sphinx.util.docutils import new_document - from mock import Mock settings = Mock(language_code='', id_prefix='', auto_id_prefix='', diff --git a/tests/test_ext_intersphinx.py b/tests/test_ext_intersphinx.py index 45684123f..93bf16834 100644 --- a/tests/test_ext_intersphinx.py +++ b/tests/test_ext_intersphinx.py @@ -11,8 +11,8 @@ import os import unittest from io import BytesIO +from unittest import mock -import mock import pytest import requests from docutils import nodes diff --git a/tests/test_ext_napoleon.py b/tests/test_ext_napoleon.py index 9127109d9..19eb536fa 100644 --- a/tests/test_ext_napoleon.py +++ b/tests/test_ext_napoleon.py @@ -10,9 +10,7 @@ """ from collections import namedtuple -from unittest import TestCase - -import mock +from unittest import TestCase, mock from sphinx.application import Sphinx from sphinx.ext.napoleon import _process_docstring, _skip_member, Config, setup diff --git a/tests/test_ext_napoleon_docstring.py b/tests/test_ext_napoleon_docstring.py index 71ac1870e..fa75062b3 100644 --- a/tests/test_ext_napoleon_docstring.py +++ b/tests/test_ext_napoleon_docstring.py @@ -12,9 +12,7 @@ from collections import namedtuple from inspect import cleandoc from textwrap import dedent -from unittest import TestCase - -import mock +from unittest import TestCase, mock from sphinx.ext.napoleon import Config from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring diff --git a/tests/test_highlighting.py b/tests/test_highlighting.py index efe2871c8..fca51d02f 100644 --- a/tests/test_highlighting.py +++ b/tests/test_highlighting.py @@ -8,7 +8,8 @@ :license: BSD, see LICENSE for details. """ -import mock +from unittest import mock + from pygments.formatters.html import HtmlFormatter from pygments.lexer import RegexLexer from pygments.token import Text, Name diff --git a/tests/test_roles.py b/tests/test_roles.py index eb4cf4ecf..8f0e546b6 100644 --- a/tests/test_roles.py +++ b/tests/test_roles.py @@ -8,8 +8,9 @@ :license: BSD, see LICENSE for details. """ +from unittest.mock import Mock + from docutils import nodes -from mock import Mock from sphinx.roles import EmphasizedLiteral from sphinx.testing.util import assert_node diff --git a/tests/test_util.py b/tests/test_util.py index 0926096f4..ae93603b8 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -10,9 +10,9 @@ import os import tempfile +from unittest.mock import patch import pytest -from mock import patch import sphinx from sphinx.errors import PycodeError diff --git a/tests/test_util_fileutil.py b/tests/test_util_fileutil.py index 635559efa..7e0d261bd 100644 --- a/tests/test_util_fileutil.py +++ b/tests/test_util_fileutil.py @@ -8,7 +8,7 @@ :license: BSD, see LICENSE for details. """ -import mock +from unittest import mock from sphinx.jinja2glue import BuiltinTemplateLoader from sphinx.util.fileutil import copy_asset, copy_asset_file