python-kdcproxy/fix-failing-tests.patch

58 lines
2.0 KiB
Diff
Raw Normal View History

From d9923b582a31cafce75ddd3a97857fa1794e22ca Mon Sep 17 00:00:00 2001
From: Christian Heimes <cheimes@redhat.com>
Date: Wed, 4 Jan 2017 15:02:00 +0100
Subject: [PATCH] Fix tests
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 <cheimes@redhat.com>
---
tests.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests.py b/tests.py
index 836f77b..9679823 100644
--- a/tests.py
+++ b/tests.py
@@ -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
@@ -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(
@@ -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)
@@ -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)