mirror of
https://github.com/certbot/certbot.git
synced 2026-01-26 07:41:33 +03:00
Remove external mock dependency (#9331)
* Remove external mock dependency This also removes the "external-mock" test environment * remove superfluous ignores * remove mock warning ignore from pytest.ini * drop deps on mock in oldest, drop dep on types-mock Co-authored-by: Alex Zorin <alex@zorin.id.au>
This commit is contained in:
@@ -18,8 +18,6 @@ jobs:
|
||||
PYTHON_VERSION: 3.7
|
||||
TOXENV: py37
|
||||
CERTBOT_NO_PIN: 1
|
||||
linux-external-mock:
|
||||
TOXENV: external-mock
|
||||
linux-boulder-v2-integration-certbot-oldest:
|
||||
PYTHON_VERSION: 3.7
|
||||
TOXENV: integration-certbot-oldest
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
"""Tests for AugeasParserNode classes"""
|
||||
from typing import List
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
import os
|
||||
import util
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
"""Test for certbot_apache._internal.configurator AutoHSTS functionality"""
|
||||
import re
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot_apache._internal import constants
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Test for certbot_apache._internal.configurator for Centos overrides"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import filesystem
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"""Test for certbot_apache._internal.configurator implementations of reverter"""
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
import util
|
||||
|
||||
@@ -5,11 +5,7 @@ import shutil
|
||||
import socket
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"""Test for certbot_apache._internal.configurator for Debian overrides"""
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Test certbot_apache._internal.display_ops."""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.display import util as display_util
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for DualParserNode implementation"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot_apache._internal import assertions
|
||||
from certbot_apache._internal import augeasparser
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Test for certbot_apache._internal.entrypoint for override class resolution"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot_apache._internal import configurator
|
||||
from certbot_apache._internal import entrypoint
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Test for certbot_apache._internal.configurator for Fedora 29+ overrides"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import filesystem
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Test for certbot_apache._internal.configurator for Gentoo overrides"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import filesystem
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import unittest
|
||||
import errno
|
||||
from typing import List
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"""Tests for certbot_apache._internal.parser."""
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for ApacheConfigurator for AugeasParserNode classes"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
import util
|
||||
|
||||
|
||||
@@ -4,11 +4,7 @@ import unittest
|
||||
|
||||
import augeas
|
||||
import josepy as jose
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot.compat import os
|
||||
from certbot.plugins import common
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
"""Tests for certbot_dns_cloudflare._internal.dns_cloudflare."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import CloudFlare
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
"""Tests for certbot_dns_digitalocean._internal.dns_digitalocean."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import digitalocean
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_dns_dnsimple._internal.dns_dnsimple."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_dns_dnsmadeeasy._internal.dns_dnsmadeeasy."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_dns_gehirn._internal.dns_gehirn."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -6,10 +6,8 @@ from googleapiclient import discovery
|
||||
from googleapiclient.errors import Error
|
||||
from googleapiclient.http import HttpMock
|
||||
from httplib2 import ServerNotFoundError
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"""Tests for certbot_dns_linode._internal.dns_linode."""
|
||||
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_dns_luadns._internal.dns_luadns."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_dns_nsone._internal.dns_nsone."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_dns_ovh._internal.dns_ovh."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
"""Tests for certbot_dns_rfc2136._internal.dns_rfc2136."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import dns.flags
|
||||
import dns.rcode
|
||||
import dns.tsig
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
"""Tests for certbot_dns_route53._internal.dns_route53.Authenticator"""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from botocore.exceptions import NoCredentialsError
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_dns_sakuracloud._internal.dns_sakuracloud."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
"""Test for certbot_nginx._internal.configurator."""
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
import OpenSSL
|
||||
|
||||
from acme import challenges
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot_nginx._internal.http_01"""
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
""" Tests for functions and classes in parser_obj.py """
|
||||
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
|
||||
from certbot_nginx._internal.parser_obj import COMMENT_BLOCK
|
||||
from certbot_nginx._internal.parser_obj import parse_raw
|
||||
|
||||
@@ -4,10 +4,7 @@ import shutil
|
||||
import tempfile
|
||||
|
||||
import josepy as jose
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
from unittest import mock
|
||||
import pkg_resources
|
||||
|
||||
from certbot import util
|
||||
|
||||
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import configobj
|
||||
import josepy as jose
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
@@ -19,12 +20,6 @@ else:
|
||||
Protocol = object
|
||||
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
|
||||
DOMAIN = 'example.com'
|
||||
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Base test class for DNS authenticators built on Lexicon."""
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import josepy as jose
|
||||
@@ -14,10 +15,6 @@ from certbot.plugins.dns_common_lexicon import LexiconClient
|
||||
from certbot.plugins.dns_test_common import _AuthenticatorCallableTestCase
|
||||
from certbot.tests import util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import Protocol
|
||||
else:
|
||||
|
||||
@@ -16,7 +16,7 @@ from typing import Iterable
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
import unittest
|
||||
import warnings
|
||||
from unittest import mock
|
||||
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
@@ -35,20 +35,6 @@ from certbot.compat import os
|
||||
from certbot.display import util as display_util
|
||||
from certbot.plugins import common
|
||||
|
||||
try:
|
||||
# When we remove this deprecated import, we should also remove the
|
||||
# "external-mock" test environment and the mock dependency listed in
|
||||
# tools/pinning/pyproject.toml.
|
||||
import mock
|
||||
warnings.warn(
|
||||
"The external mock module is being used for backwards compatibility "
|
||||
"since it is available, however, future versions of Certbot's tests will "
|
||||
"use unittest.mock. Be sure to update your code accordingly.",
|
||||
PendingDeprecationWarning
|
||||
)
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
|
||||
|
||||
class DummyInstaller(common.Installer):
|
||||
"""Dummy installer plugin for test purpose."""
|
||||
|
||||
@@ -90,7 +90,6 @@ test_extras = [
|
||||
'pytest-xdist',
|
||||
'setuptools',
|
||||
'tox',
|
||||
'types-mock',
|
||||
'types-pyOpenSSL',
|
||||
'types-pyRFC3339',
|
||||
'types-pytz',
|
||||
|
||||
@@ -4,10 +4,7 @@ import json
|
||||
import unittest
|
||||
|
||||
import josepy as jose
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
import pytz
|
||||
|
||||
from acme import messages
|
||||
|
||||
@@ -4,10 +4,7 @@ import logging
|
||||
import unittest
|
||||
|
||||
from josepy import b64encode
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from acme import client as acme_client
|
||||
|
||||
@@ -7,10 +7,7 @@ import tempfile
|
||||
import unittest
|
||||
|
||||
import configobj
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors, configuration
|
||||
from certbot._internal.storage import ALL_FOUR
|
||||
|
||||
@@ -5,6 +5,7 @@ from importlib import reload as reload_module
|
||||
import io
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import errors
|
||||
@@ -16,11 +17,6 @@ from certbot.compat import os
|
||||
import certbot.tests.util as test_util
|
||||
from certbot.tests.util import TempDirTestCase
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
PLUGINS = disco.PluginsRegistry.find_all()
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import platform
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from josepy import interfaces
|
||||
@@ -17,11 +18,6 @@ from certbot._internal import constants
|
||||
from certbot.compat import os
|
||||
import certbot.tests.util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
KEY = test_util.load_vector("rsa512_key.pem")
|
||||
CSR_SAN = test_util.load_vector("csr-san_512.pem")
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import contextlib
|
||||
import errno
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import util
|
||||
from certbot._internal import lock
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for certbot.compat.misc"""
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock # type: ignore
|
||||
import unittest
|
||||
import warnings
|
||||
from unittest import mock
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for certbot.configuration."""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot._internal import constants
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot.crypto_util."""
|
||||
import logging
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
import OpenSSL
|
||||
|
||||
from certbot import errors
|
||||
|
||||
@@ -9,17 +9,12 @@ from importlib import reload as reload_module
|
||||
import string
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from certbot.compat import filesystem
|
||||
from certbot.compat import os
|
||||
import certbot.tests.util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
|
||||
class CompleterTest(test_util.TempDirTestCase):
|
||||
"""Test certbot._internal.display.completer.Completer."""
|
||||
|
||||
@@ -3,15 +3,11 @@ import io
|
||||
import socket
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from acme import messages as acme_messages
|
||||
from certbot import errors
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
class WrapLinesTest(unittest.TestCase):
|
||||
def test_wrap_lines(self):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"""Test certbot.display.ops."""
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
|
||||
@@ -15,11 +16,6 @@ from certbot.display import ops
|
||||
from certbot.display import util as display_util
|
||||
import certbot.tests.util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
|
||||
|
||||
|
||||
@@ -3,15 +3,11 @@ import io
|
||||
import socket
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
import certbot.tests.util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
class NotifyTest(unittest.TestCase):
|
||||
"""Tests for certbot.display.util.notify"""
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Tests for certbot._internal.eff."""
|
||||
import datetime
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
import josepy
|
||||
import pytz
|
||||
import requests
|
||||
|
||||
@@ -6,15 +6,10 @@ from typing import Callable
|
||||
from typing import Dict
|
||||
from typing import Union
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
|
||||
def get_signals(signums):
|
||||
"""Get the handlers for an iterable of signums."""
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for certbot.errors."""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from acme import messages
|
||||
from certbot import achallenges
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for certbot.helpful_parser"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot._internal.cli import HelpfulArgumentParser
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for certbot._internal.hooks."""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot import util
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import functools
|
||||
import multiprocessing
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -6,6 +6,7 @@ import sys
|
||||
import time
|
||||
from typing import Optional
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from acme import messages
|
||||
from certbot import errors
|
||||
@@ -15,11 +16,6 @@ from certbot.compat import filesystem
|
||||
from certbot.compat import os
|
||||
from certbot.tests import util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
|
||||
class PreArgParseSetupTest(unittest.TestCase):
|
||||
|
||||
@@ -12,6 +12,7 @@ import tempfile
|
||||
import traceback
|
||||
from typing import List
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
import pytz
|
||||
@@ -34,11 +35,6 @@ from certbot.compat import os
|
||||
from certbot.plugins import enhancements
|
||||
import certbot.tests.util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
|
||||
CERT_PATH = test_util.vector_path('cert_512.pem')
|
||||
|
||||
@@ -4,6 +4,7 @@ import contextlib
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from cryptography import x509
|
||||
from cryptography.exceptions import InvalidSignature
|
||||
@@ -16,11 +17,6 @@ import pytz
|
||||
from certbot import errors
|
||||
from certbot.tests import util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
out = """Missing = in header key=value
|
||||
ocsp: Use -help for summary.
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
import functools
|
||||
import shutil
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
|
||||
@@ -3,6 +3,7 @@ import functools
|
||||
import string
|
||||
from typing import List
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pkg_resources
|
||||
|
||||
@@ -12,11 +13,6 @@ from certbot._internal.plugins import null
|
||||
from certbot._internal.plugins import standalone
|
||||
from certbot._internal.plugins import webroot
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
EP_SA = pkg_resources.EntryPoint(
|
||||
"sa", "certbot._internal.plugins.standalone",
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"""Tests for certbot.plugins.dns_common_lexicon."""
|
||||
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot.plugins import dns_common_lexicon
|
||||
from certbot.plugins import dns_test_common_lexicon
|
||||
|
||||
@@ -3,11 +3,7 @@
|
||||
import collections
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot import util
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for new style enhancements"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot._internal.plugins import null
|
||||
from certbot.plugins import enhancements
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import sys
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import errors
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for certbot._internal.plugins.null."""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
|
||||
class InstallerTest(unittest.TestCase):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import sys
|
||||
from typing import List
|
||||
import unittest
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
@@ -11,11 +11,6 @@ from certbot._internal.plugins.disco import PluginsRegistry
|
||||
from certbot.display import util as display_util
|
||||
from certbot.tests import util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
class ConveniencePickPluginTest(unittest.TestCase):
|
||||
"""Tests for certbot._internal.plugins.selection.pick_*."""
|
||||
|
||||
@@ -5,6 +5,7 @@ from typing import Dict
|
||||
from typing import Set
|
||||
from typing import Tuple
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
import OpenSSL.crypto
|
||||
@@ -16,11 +17,6 @@ from certbot import errors
|
||||
from certbot.tests import acme_util
|
||||
from certbot.tests import util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
class ServerManagerTest(unittest.TestCase):
|
||||
"""Tests for certbot._internal.plugins.standalone.ServerManager."""
|
||||
|
||||
@@ -4,17 +4,13 @@ from typing import Iterable
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import filesystem
|
||||
from certbot.compat import os
|
||||
from certbot.tests import util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
|
||||
class PluginStorageTest(test_util.ConfigTestCase):
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for certbot.plugins.util."""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
|
||||
@@ -8,12 +8,9 @@ import json
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
"""Tests for certbot._internal.renewal"""
|
||||
import copy
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from acme import challenges
|
||||
from certbot import errors, configuration
|
||||
from certbot._internal import storage
|
||||
import certbot.tests.util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
|
||||
class RenewalTest(test_util.ConfigTestCase):
|
||||
@mock.patch('certbot._internal.cli.set_by_cli')
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""Tests for renewal updater interfaces"""
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import interfaces
|
||||
from certbot._internal import main
|
||||
|
||||
@@ -4,11 +4,7 @@ import logging
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import os
|
||||
|
||||
@@ -4,12 +4,9 @@ import datetime
|
||||
import shutil
|
||||
import stat
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import configobj
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
import pytz
|
||||
|
||||
import certbot
|
||||
|
||||
@@ -5,18 +5,13 @@ from importlib import reload as reload_module
|
||||
import io
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import filesystem
|
||||
from certbot.compat import os
|
||||
import certbot.tests.util as test_util
|
||||
|
||||
try:
|
||||
import mock
|
||||
except ImportError: # pragma: no cover
|
||||
from unittest import mock
|
||||
|
||||
|
||||
|
||||
class EnvNoSnapForExternalCallsTest(unittest.TestCase):
|
||||
"""Tests for certbot.util.env_no_snap_for_external_calls."""
|
||||
|
||||
10
pytest.ini
10
pytest.ini
@@ -11,14 +11,12 @@
|
||||
# we release breaking changes.
|
||||
#
|
||||
# The current warnings being ignored are:
|
||||
# 1) The warning raised when importing certbot.tests.util and the external mock
|
||||
# library is installed.
|
||||
# 2) A deprecation warning is raised in dnspython==1.15.0 in the oldest tests for
|
||||
# 1) A deprecation warning is raised in dnspython==1.15.0 in the oldest tests for
|
||||
# certbot-dns-rfc2136.
|
||||
# 3) botocore is currently using deprecated urllib3 functionality. See
|
||||
# https://github.com/boto/botocore/issues/2744.
|
||||
# 2) botocore's default TLS settings raise deprecation warnings in Python
|
||||
# 3.10+, but their values are sane from a security perspective. See
|
||||
# https://github.com/boto/botocore/issues/2550.
|
||||
filterwarnings =
|
||||
error
|
||||
ignore:The external mock module:PendingDeprecationWarning
|
||||
ignore:decodestring\(\) is a deprecated alias:DeprecationWarning:dns
|
||||
ignore:'urllib3.contrib.pyopenssl:DeprecationWarning:botocore
|
||||
|
||||
@@ -45,7 +45,6 @@ jsonschema==3.2.0; python_version >= "3.7"
|
||||
lazy-object-proxy==1.7.1; python_version >= "3.7"
|
||||
logger==1.4; python_version >= "3.7"
|
||||
mccabe==0.7.0; python_version >= "3.7"
|
||||
mock==1.0.1
|
||||
mypy-extensions==0.4.3; python_version >= "3.7"
|
||||
mypy==0.971; python_version >= "3.7"
|
||||
ndg-httpsclient==0.3.2
|
||||
@@ -92,7 +91,6 @@ tomli==2.0.1; python_version < "3.11" and python_version >= "3.7" or python_full
|
||||
tox==1.9.2; python_version >= "3.7"
|
||||
typed-ast==1.5.4; python_version >= "3.7" and python_version < "3.8" or implementation_name == "cpython" and python_version < "3.8" and python_version >= "3.7"
|
||||
types-cryptography==3.3.21; python_version >= "3.7"
|
||||
types-mock==4.0.15; python_version >= "3.7"
|
||||
types-pyopenssl==22.0.9; python_version >= "3.7"
|
||||
types-pyrfc3339==1.1.1; python_version >= "3.7"
|
||||
types-python-dateutil==2.8.19; python_version >= "3.7"
|
||||
|
||||
@@ -50,13 +50,6 @@ awscli = ">=1.22.76"
|
||||
# as a dependency here to ensure a version of cython is pinned for extra
|
||||
# stability.
|
||||
cython = "*"
|
||||
# We install mock in our "external-mock" tox environment to test that we didn't
|
||||
# break Certbot's test API which used to always use mock objects from the 3rd
|
||||
# party mock library. We list the mock dependency here so that is pinned, but
|
||||
# we don't depend on it in Certbot to avoid installing mock when it's not
|
||||
# needed. This dependency can be removed here once Certbot's support for the
|
||||
# 3rd party mock library has been dropped.
|
||||
mock = "*"
|
||||
# poetry 1.2.0+ is required for it to pin pip, setuptools, and wheel. See
|
||||
# https://github.com/python-poetry/poetry/issues/1584. This version is required
|
||||
# here in addition to certbot/setup.py because otherwise the pre-release
|
||||
|
||||
@@ -61,7 +61,6 @@ google-api-python-client = "1.5.5"
|
||||
httplib2 = "0.9.2"
|
||||
idna = "2.6"
|
||||
ipaddress = "1.0.16"
|
||||
mock = "1.0.1"
|
||||
ndg-httpsclient = "0.3.2"
|
||||
oauth2client = "4.0.0"
|
||||
parsedatetime = "2.4"
|
||||
|
||||
@@ -84,7 +84,6 @@ lockfile==0.12.2
|
||||
markupsafe==2.1.1; python_version >= "3.7"
|
||||
matplotlib-inline==0.1.3; python_version >= "3.7"
|
||||
mccabe==0.7.0; python_version >= "3.7"
|
||||
mock==4.0.3
|
||||
msgpack==1.0.4; python_version >= "3.7" and python_version < "4.0"
|
||||
msrest==0.6.21; python_version >= "3.7"
|
||||
mypy-extensions==0.4.3; python_version >= "3.7"
|
||||
@@ -170,7 +169,6 @@ traitlets==5.3.0; python_version >= "3.7"
|
||||
twine==3.3.0; python_version >= "3.7"
|
||||
typed-ast==1.5.4; python_version >= "3.7" and python_version < "3.8" or implementation_name == "cpython" and python_version < "3.8" and python_version >= "3.7"
|
||||
types-cryptography==3.3.21; python_version >= "3.7"
|
||||
types-mock==4.0.15; python_version >= "3.7"
|
||||
types-pyopenssl==22.0.9; python_version >= "3.7"
|
||||
types-pyrfc3339==1.1.1; python_version >= "3.7"
|
||||
types-python-dateutil==2.8.19; python_version >= "3.7"
|
||||
|
||||
5
tox.ini
5
tox.ini
@@ -112,11 +112,6 @@ commands =
|
||||
setenv =
|
||||
{[testenv:oldest]setenv}
|
||||
|
||||
[testenv:external-mock]
|
||||
commands =
|
||||
python {toxinidir}/tools/pip_install.py mock
|
||||
{[base]install_and_test} {[base]all_packages}
|
||||
|
||||
[testenv:lint{,-win,-posix}]
|
||||
basepython = python3
|
||||
# separating into multiple invocations disables cross package
|
||||
|
||||
Reference in New Issue
Block a user