diff --git a/libcloud/test/__init__.py b/libcloud/test/__init__.py index d45c82c84d..1cc595f685 100644 --- a/libcloud/test/__init__.py +++ b/libcloud/test/__init__.py @@ -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. @@ -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