-
Notifications
You must be signed in to change notification settings - Fork 347
Getting error "setUpClass should be a classmethod" #597
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
Comments
Thanks for the report. I guess it should be wrapped with a The commit is quite old, but likely was only released recently then? (96f5fb1) It's good to have a test case. |
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 pytest-dev#597
Actually, after sleeping on it I think just adding a try/except isn't enough: at the point the exception is thrown the method has been set back, so this can't be the issue. More digging revealed the actual problem: the classmethod test was incorrect. The testcase can be made even simpler: replacing the setUpClass with just pass still break. Making a pull request 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 pytest-dev#597
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 pytest-dev#597
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 pytest-dev#597
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 pytest-dev#597
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 pytest-dev#597
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 pytest-dev#597
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 pytest-dev#597
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 pytest-dev#597
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 pytest-dev#597
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
Ok, buildbot passed my patch. Actually two bugs in the end, but now it all works :) |
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/pytest-django#597
Recently some magic was added that tries wrap the setUpClass methods for some reason. Not sure why. In any case, it breaks our testsuite. I've attached a test file to reproduce.
The basic issue is that the the setUpClass raises a skip exception sometimes to cause the methods defined in that class to be skipped. This causes the wrapping code to skip restoring the classmethod, leading to errors later on.
The error is in this code:
pytest-django/pytest_django/plugin.py
Lines 417 to 419 in a67ab3b
If the setUpClass() throws an exception (in this case Skip), the restore is skipped and chaos ensues.
This is a test file that reproduces it:
The text was updated successfully, but these errors were encountered: