Skip to content

Commit 1117987

Browse files
authored
Merge pull request #2033 from s-t-e-v-e-n-k/only-call-super-if-needed
Only call super() during MockHttp if required
2 parents 161e446 + fed3944 commit 1117987

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ Other / Development
135135
(#1994)
136136
[Tomaz Muraus - @Kami]
137137

138+
- Add a workaround so tests work with pytest >= 8.2. Also use latest version of
139+
pytest for running tests.
140+
(#2033)
141+
[Steve Kowalik - @s-t-e-v-e-n-k]
142+
138143
Changes in Apache Libcloud 3.8.0
139144
--------------------------------
140145

libcloud/test/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def read(self, chunk_size=None):
8787
return StringIO.read(self)
8888

8989

90-
class MockHttp(LibcloudConnection):
90+
class MockHttp(LibcloudConnection, unittest.TestCase):
9191
"""
9292
A mock HTTP client/server suitable for testing purposes. This replaces
9393
`HTTPConnection` by implementing its API and returning a mock response.
@@ -108,7 +108,11 @@ def __init__(self, *args, **kwargs):
108108
# within a response
109109
if isinstance(self, unittest.TestCase):
110110
unittest.TestCase.__init__(self, "__init__")
111-
super().__init__(*args, **kwargs)
111+
# When this class is collected, it is instantiated with no arguments,
112+
# which breaks any superclasses that expect arguments, so only
113+
# do so if we were passed any keyword arguments.
114+
if kwargs:
115+
super().__init__(*args, **kwargs)
112116

113117
def _get_request(self, method, url, body=None, headers=None):
114118
# Find a method we can use for this request

requirements-tests.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
coverage[toml]==7.2.7; python_version >= '3.8'
22
requests>=2.31.0
33
requests_mock==1.11.0
4-
pytest==8.1.1
5-
pytest-xdist==3.5.0
6-
pytest-timeout==2.2.0
7-
pytest-benchmark[histogram]==4.0.0
4+
pytest==8.3.5
5+
pytest-xdist==3.6.1
6+
pytest-timeout==2.3.1
7+
pytest-benchmark[histogram]==5.1.0
88
cryptography==44.0.2
99

1010
# NOTE: Only needed by nttcis loadbalancer driver

0 commit comments

Comments
 (0)