← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 2019772] [NEW] nova.test.SubclassSignatureTestCase no longer works

 

Public bug reported:

I found this the hard way while working on a patch that added a keyword
argument to the signature of
nova.virt.libvirt.volume.LibvirtBaseVolumeDriver.disconnect_volume.

I had missed updating some of the volume drivers and
LibvirtBaseVolumeDriverSubclassSignatureTestCase.test_signatures should
have caught it ... but it didn't because it was not actually checking
any signatures.

After some digging, I found that SubclassSignatureTestCase has not worked properly since we dropped support for python 2.7. The reason is the use of the inspect.ismethod() function; in python 2.7 
it returned true if the object was a bound or an unbound method [2] but as of python 3, it only returns true if the object is a bound method [2].

So in this code [3]:

        # 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):

inspect.getmembers(cls, inspect.ismethod) never returns any methods
because none of them are bound.

As of python 3,  we need to use inspect.isfunction() instead.

[1] https://docs.python.org/2.7/library/inspect.html#inspect.ismethod
[2] https://docs.python.org/3.5/library/inspect.html#inspect.ismethod
[3] https://github.com/openstack/nova/blob/b3fdd7c/nova/test.py#L718

** Affects: nova
     Importance: Undecided
     Assignee: melanie witt (melwitt)
         Status: In Progress


** Tags: testing

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/2019772

Title:
  nova.test.SubclassSignatureTestCase no longer works

Status in OpenStack Compute (nova):
  In Progress

Bug description:
  I found this the hard way while working on a patch that added a
  keyword argument to the signature of
  nova.virt.libvirt.volume.LibvirtBaseVolumeDriver.disconnect_volume.

  I had missed updating some of the volume drivers and
  LibvirtBaseVolumeDriverSubclassSignatureTestCase.test_signatures
  should have caught it ... but it didn't because it was not actually
  checking any signatures.

  After some digging, I found that SubclassSignatureTestCase has not worked properly since we dropped support for python 2.7. The reason is the use of the inspect.ismethod() function; in python 2.7 
  it returned true if the object was a bound or an unbound method [2] but as of python 3, it only returns true if the object is a bound method [2].

  So in this code [3]:

          # 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):

  inspect.getmembers(cls, inspect.ismethod) never returns any methods
  because none of them are bound.

  As of python 3,  we need to use inspect.isfunction() instead.

  [1] https://docs.python.org/2.7/library/inspect.html#inspect.ismethod
  [2] https://docs.python.org/3.5/library/inspect.html#inspect.ismethod
  [3] https://github.com/openstack/nova/blob/b3fdd7c/nova/test.py#L718

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/2019772/+subscriptions



Follow ups