Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Python 2's mock is no longer compatible to more recent versions of
Python's socket module. Tests are still fine without the autospec
feature.

More recent versions of pytests refuse to load tests because pytest
considers webtest.TestApp as a test class with a non-trival __init__.

Signed-off-by: Christian Heimes <[email protected]>
  • Loading branch information
tiran committed Jan 4, 2017
1 parent 5edbbeb commit d9923b5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from pyasn1.codec.der import decoder, encoder

from webtest import TestApp
from webtest import TestApp as WebTestApp

import kdcproxy
# from kdcproxy import asn1
Expand All @@ -59,7 +59,7 @@ def setUp(self): # noqa
self.await_reply.return_value = b'RESPONSE'
self.resolver = self.app._Application__resolver = mock.Mock()
self.resolver.lookup.return_value = ["kerberos://k1.kdcproxy.test.:88"]
self.tapp = TestApp(self.app)
self.tapp = WebTestApp(self.app)

def post(self, body, expect_errors=False):
return self.tapp.post(
Expand All @@ -79,7 +79,7 @@ def test_get(self):
self.assertEqual(r.text, 'Method not allowed (GET).')

@mock.patch('socket.getaddrinfo', return_value=addrinfo)
@mock.patch('socket.socket', autospec=True)
@mock.patch('socket.socket')
def test_post_asreq(self, m_socket, m_getaddrinfo):
response = self.post(KDCProxyCodecTests.asreq1)
self.assert_response(response)
Expand All @@ -92,7 +92,7 @@ def test_post_asreq(self, m_socket, m_getaddrinfo):
)

@mock.patch('socket.getaddrinfo', return_value=addrinfo)
@mock.patch('socket.socket', autospec=True)
@mock.patch('socket.socket')
def test_post_kpasswd(self, m_socket, m_getaddrinfo):
response = self.post(KDCProxyCodecTests.kpasswdreq)
self.assert_response(response)
Expand Down

0 comments on commit d9923b5

Please sign in to comment.