Skip to content

Commit

Permalink
Use mock.create_autospec on mocked interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Apr 25, 2018
1 parent 794872d commit 49adeda
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions 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
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 49adeda

Please sign in to comment.