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
|
||||
# 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.
|
||||
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
|
||||
if name == '__init__':
|
||||
continue
|
||||
|
||||
# Skip subclass private functions
|
||||
if name.startswith('_'):
|
||||
continue
|
||||
|
||||
while hasattr(method, '__wrapped__'):
|
||||
# This is a wrapped function. The signature we're going to
|
||||
# see here is that of the wrapper, which is almost certainly
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
import os.path
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
@ -415,3 +416,21 @@ class PatchOpenTestCase(test.NoDBTestCase):
|
||||
without changing other file operations.
|
||||
"""
|
||||
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(
|
||||
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."""
|
||||
LOG.debug("calling os-brick to extend LightOS Volume."
|
||||
"instance:%s, volume_id:%s",
|
||||
|
Loading…
Reference in New Issue
Block a user