Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only call super() during MockHttp if required #2033

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions libcloud/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def read(self, chunk_size=None):
return StringIO.read(self)


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

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