summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSethMichaelLarson <sethmichaellarson@protonmail.com>2018-04-02 19:26:50 -0500
committerSeth Michael Larson <sethmichaellarson@protonmail.com>2018-04-25 12:51:18 -0500
commit49adeda78c79756fe1cc71e697fb367c16d18d2c (patch)
treec9a38a8c723cfd920ef30c1ce390bbed494f5eae /test
parent794872d15f4c0fc1087dc45abe2fe5f1fb46445e (diff)
downloadurllib3-49adeda78c79756fe1cc71e697fb367c16d18d2c.tar.gz
Use mock.create_autospec on mocked interfaces
Diffstat (limited to 'test')
-rw-r--r--test/test_ssl.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/test_ssl.py b/test/test_ssl.py
index 82171234..20b45ba5 100644
--- a/test/test_ssl.py
+++ b/test/test_ssl.py
@@ -1,5 +1,6 @@
import mock
import pytest
+import socket
from six import b
from urllib3.util import ssl_
from urllib3.exceptions import SNIMissingWarning
@@ -36,8 +37,8 @@ def test_is_ipaddress_false(addr):
def test_context_sni_with_ip_address(monkeypatch, has_sni, server_hostname, uses_sni):
monkeypatch.setattr(ssl_, 'HAS_SNI', has_sni)
- sock = mock.Mock()
- context = mock.Mock()
+ sock = mock.create_autospec(socket.socket)
+ context = mock.create_autospec(ssl_.SSLContext)
ssl_.ssl_wrap_socket(sock, server_hostname=server_hostname, ssl_context=context)
@@ -59,8 +60,8 @@ def test_context_sni_with_ip_address(monkeypatch, has_sni, server_hostname, uses
def test_sni_missing_warning_with_ip_addresses(monkeypatch, has_sni, server_hostname, should_warn):
monkeypatch.setattr(ssl_, 'HAS_SNI', has_sni)
- sock = mock.Mock()
- context = mock.Mock()
+ sock = mock.create_autospec(socket.socket)
+ context = mock.create_autospec(ssl_.SSLContext)
with mock.patch('warnings.warn') as warn:
ssl_.ssl_wrap_socket(sock, server_hostname=server_hostname, ssl_context=context)