Merge "testing: Use inspect.isfunction() to check signatures"
This commit is contained in:
commit
681f6872fb
@ -726,11 +726,15 @@ class SubclassSignatureTestCase(testtools.TestCase, metaclass=abc.ABCMeta):
|
|||||||
# getmembers returns all members, including members inherited from
|
# getmembers returns all members, including members inherited from
|
||||||
# the base class. It's redundant for us to test these, but as
|
# the base class. It's redundant for us to test these, but as
|
||||||
# they'll always pass it's not worth the complexity to filter them out.
|
# they'll always pass it's not worth the complexity to filter them out.
|
||||||
for (name, method) in inspect.getmembers(cls, inspect.ismethod):
|
for (name, method) in inspect.getmembers(cls, inspect.isfunction):
|
||||||
# Subclass __init__ methods can usually be legitimately different
|
# Subclass __init__ methods can usually be legitimately different
|
||||||
if name == '__init__':
|
if name == '__init__':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Skip subclass private functions
|
||||||
|
if name.startswith('_'):
|
||||||
|
continue
|
||||||
|
|
||||||
while hasattr(method, '__wrapped__'):
|
while hasattr(method, '__wrapped__'):
|
||||||
# This is a wrapped function. The signature we're going to
|
# This is a wrapped function. The signature we're going to
|
||||||
# see here is that of the wrapper, which is almost certainly
|
# see here is that of the wrapper, which is almost certainly
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -415,3 +416,21 @@ class PatchOpenTestCase(test.NoDBTestCase):
|
|||||||
without changing other file operations.
|
without changing other file operations.
|
||||||
"""
|
"""
|
||||||
self._test_patched_open()
|
self._test_patched_open()
|
||||||
|
|
||||||
|
|
||||||
|
class SubclassSignatureTestCaseTestCase(test.SubclassSignatureTestCase):
|
||||||
|
class Baseclass():
|
||||||
|
def method(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Subclass(Baseclass):
|
||||||
|
def method(self, different):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _get_base_class(self):
|
||||||
|
return SubclassSignatureTestCaseTestCase.Baseclass
|
||||||
|
|
||||||
|
@unittest.expectedFailure
|
||||||
|
def test_signatures(self):
|
||||||
|
# Test that the signature check fails when it's supposed to fail.
|
||||||
|
super().test_signatures()
|
||||||
|
@ -52,7 +52,7 @@ class LibvirtLightOSVolumeDriver(libvirt_volume.LibvirtVolumeDriver):
|
|||||||
super(LibvirtLightOSVolumeDriver, self).disconnect_volume(
|
super(LibvirtLightOSVolumeDriver, self).disconnect_volume(
|
||||||
connection_info, instance, force=force)
|
connection_info, instance, force=force)
|
||||||
|
|
||||||
def extend_volume(self, connection_info, instance, requested_size=None):
|
def extend_volume(self, connection_info, instance, requested_size):
|
||||||
"""Extend the volume."""
|
"""Extend the volume."""
|
||||||
LOG.debug("calling os-brick to extend LightOS Volume."
|
LOG.debug("calling os-brick to extend LightOS Volume."
|
||||||
"instance:%s, volume_id:%s",
|
"instance:%s, volume_id:%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user