Skip to content

Commit

Permalink
Fix #728: attrib plugin rejects any staticmethod
Browse files Browse the repository at this point in the history
The issue is that static methods get wrapped in an UnboundMethod object,
and the attribute plugin is unable to grab the associated class, since
UnboundMethod does not have the im_class attribute.  Since the goal of
UnboundMethod is to mimic an actual method, let's go ahead and implement
the im_class attribute.
  • Loading branch information
jszakmeister committed Feb 20, 2014
1 parent 023124f commit c51ff6f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ In Development
- Fix #771: attr plugin is broken when parent and child share same method
name with different attributes
Patch by John Szakmeister. Test case provided by Thomas Grainger.
- Fix #728: attrib plugin rejects any staticmethod
Patch by John Szakmesiter. Test case provided by Thomas Kluyver.

1.3.0

Expand Down
10 changes: 10 additions & 0 deletions functional_tests/test_attribute_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ def verify(self):
assert 'TestDerived' not in self.output


# Issue #728
class TestStaticMethod(AttributePluginTester):
suitepath = os.path.join(support, 'attrib-static')
args = ["-a", "!slow"]

def verify(self):
assert 'test.TestAttrib.test_static ... ok' in self.output
assert 'Ran 1 test' in self.output


if compat_24:
class TestAttributeEval(AttributePluginTester):
args = ["-A", "c>20"]
Expand Down
1 change: 1 addition & 0 deletions nose/pyversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(self, cls, func):
self.__dict__ = func.__dict__.copy()
self._func = func
self.__self__ = UnboundSelf(cls)
self.im_class = cls

def address(self):
cls = self.__self__.cls
Expand Down

0 comments on commit c51ff6f

Please sign in to comment.