Fix #6140: Use unittest.mock instead of mock

This commit is contained in:
Takeshi KOMIYA 2019-03-07 23:35:36 +09:00
parent 177246a49e
commit 65970a3033
15 changed files with 25 additions and 24 deletions

View File

@ -39,7 +39,6 @@ extras_require = {
'colorama>=0.3.5',
],
'test': [
'mock',
'pytest',
'pytest-cov',
'html5lib',

View File

@ -10,8 +10,8 @@
import sys
from textwrap import dedent
from unittest import mock
import mock
import pytest
from docutils import nodes

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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='',

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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