-
Notifications
You must be signed in to change notification settings - Fork 346
Fix classmethod test. #598
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
It's not passing the tests. Test case that this fixes:
|
831bee2
to
e4d4451
Compare
Thanks for fixing this (changed in a67ab3b by myself). Tests are currently failing, but it looks like it is related to matching the output only. |
I'll see if I can make it less strict, but it would be nice indeed if we could prevent those messages appearing. This test doesn't require a database... |
5261c01
to
0fc5220
Compare
Ok, the tests are now fine, but a test case fails. I'm pretty sure this indicates some other bug which I'm not sure how to fix. I'm having difficulty testing on my local setup, but I'll keep trying. |
This test was incorrect in the case where the method was inherited from a subclass. Which ironically is precisely what the function was supposed to test. Additionally, there was a problem where the restored methods were bound to the wrong class. Added test case and fixed that also. Fixes pytest-dev#597
Codecov Report
@@ Coverage Diff @@
## master #598 +/- ##
==========================================
- Coverage 91.92% 87.95% -3.98%
==========================================
Files 33 33
Lines 1660 1660
Branches 143 143
==========================================
- Hits 1526 1460 -66
- Misses 95 145 +50
- Partials 39 55 +16
Continue to review full report at Codecov.
|
I guess that's just implied with tests based on Django's TestCase I assume. |
Thanks, slightly amended and merged in 9b7f47b. diff --git c/pytest_django/plugin.py i/pytest_django/plugin.py
index 2164f13..1336f90 100644
--- c/pytest_django/plugin.py
+++ i/pytest_django/plugin.py
@@ -292,8 +292,8 @@ def _disable_class_methods(cls):
return
_disabled_classmethods[cls] = (
- # want the classmethod object, not the resulting bound method
- # otherwise when restoring, the inheritence will be broken
+ # Get the classmethod object (not the resulting bound method),
+ # otherwise inheritence will be broken when restoring.
cls.__dict__.get('setUpClass'),
_classmethod_is_defined_at_leaf(cls, 'setUpClass'),
cls.__dict__.get('tearDownClass'), |
I have a case of using a mixin on my test classes that started failing with 3.3.0 in upgrade PR adamchainz/django-mysql#484. It was caused by pytest-dev#598. It looks like this was actually a latent failure in the way `_classmethod_is_defined_at_leaf` was picking the 'super method' - it would iterate further up the tree despite coming across the next method in the resolution chain. Also by not using `__mro__` the order of the base classes wasn't strictly being observed, although I don't think that affects my mixin case. Added a test that fails before and passes after.
Fixes regression in #598. It looks like this was actually a latent failure in the way `_classmethod_is_defined_at_leaf` was picking the 'super method' - it would iterate further up the tree despite coming across the next method in the resolution chain. Also by not using `__mro__` the order of the base classes wasn't strictly being observed, although I don't think that affects my mixin case. Added a test that fails before and passes after. Closes #618.
Thanks for fixing this - just noticed that DRF is also affected by this. Releasing 3.3.1 now. |
This test was incorrect in the case where the method was inherited from a
subclass. Which ironically is precisely what the function was supposed to
test.
Fixes #597