-
Notifications
You must be signed in to change notification settings - Fork 346
Fix another unittest regression (#624) #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #625 +/- ##
==========================================
+ Coverage 92.33% 92.36% +0.02%
==========================================
Files 32 32
Lines 1710 1715 +5
Branches 142 142
==========================================
+ Hits 1579 1584 +5
Misses 94 94
Partials 37 37
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a more correct fix, updating _classmethod_is_defined_at_leaf
to check in __dict__
like the other code
diff --git a/pytest_django/plugin.py b/pytest_django/plugin.py
index 3a82b62..5d4f323 100644
--- a/pytest_django/plugin.py
+++ b/pytest_django/plugin.py
@@ -268,8 +268,8 @@ def _classmethod_is_defined_at_leaf(cls, method_name):
super_method = None
for base_cls in cls.__mro__[1:]: # pragma: no branch
- if hasattr(base_cls, method_name):
- super_method = getattr(base_cls, method_name)
+ super_method = base_cls.__dict__.get(method_name)
+ if super_method is not None:
break
assert super_method is not None, (
@@ -295,16 +295,12 @@ def _disable_class_methods(cls):
if cls in _disabled_classmethods:
return
- # Get the classmethod object (not the resulting bound method),
- # otherwise inheritence will be broken when restoring.
- # But fall back to bound method in case it is None in __dict__.
- setUpClass = cls.__dict__.get('setUpClass', cls.setUpClass)
- tearDownClass = cls.__dict__.get('tearDownClass', cls.tearDownClass)
-
_disabled_classmethods[cls] = (
- setUpClass,
+ # Get the classmethod object (not the resulting bound method),
+ # otherwise inheritance will be broken when restoring.
+ cls.__dict__.get('setUpClass'),
_classmethod_is_defined_at_leaf(cls, 'setUpClass'),
- tearDownClass,
+ cls.__dict__.get('tearDownClass'),
_classmethod_is_defined_at_leaf(cls, 'tearDownClass'),
)
Thanks, @adamchainz! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Fixes #624.