Skip to content
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

TestCase inheritance breaks with setUpTestData (Django 1.8) #265

Closed
bforchhammer opened this issue Sep 23, 2015 · 4 comments
Closed

TestCase inheritance breaks with setUpTestData (Django 1.8) #265

bforchhammer opened this issue Sep 23, 2015 · 4 comments

Comments

@bforchhammer
Copy link

Hi,

We have a large test base with test cases which inherit from each other. I am in the process of converting them to Django 1.8 and tried to use the new setUpTestData class method for setting up test data.

This fails in a very strange way for tests using inheritance: setUpTestData is only invoked for the base class and not for the derived class. I think this may be because of this commit, which changes and overrides setUpClass and tearDownClass in a way which I honestly don't quite understand...

I have created a failing test which shows the problem; the lines which cause errors are annotated with TODO comments.

Any ideas on how to fix or circumvent this problem are greatly appreciated! :-)

@blueyed
Copy link
Contributor

blueyed commented Sep 23, 2015

Yes, it looks like the new instancemethods should use super() to call the parents..

I think the way forward would be to create a PR with your failing test (great!), and then try to fix it from there.

@pelme
Copy link
Member

pelme commented Sep 28, 2015

Thanks for the test case, that should make a fix for this much easier!

I'd like to have this fixed before the next release, I will try to take a stab at it the next couple of days if no one else wants to give it a try.

@pelme
Copy link
Member

pelme commented Oct 3, 2015

@bforchhammer I have a fix for this in PR #277 - could you give it a try and make sure it fixes your problem?

pip install -e git+https://github.com/pelme/pytest-django.git@multi-inheritance-testcase#egg=pytest-django

pelme added a commit to pelme/pytest-django that referenced this issue Oct 4, 2015
pelme added a commit that referenced this issue Oct 4, 2015
…ritance

pytest-django monkeypatches Django's setUpClass / tearDownClass to call
them at the correct time during fixture setup/teardown. The previous
implementation caused problems when used with multiple inheritance.

This commit fixes issue #265.
@pelme
Copy link
Member

pelme commented Oct 4, 2015

The fix is now merged in master, I'm closing this issue now. Please re-open if there are any problems with the fix!

@pelme pelme closed this as completed Oct 4, 2015
tomviner pushed a commit to tomviner/pytest-django that referenced this issue Jun 22, 2016
…ritance

pytest-django monkeypatches Django's setUpClass / tearDownClass to call
them at the correct time during fixture setup/teardown. The previous
implementation caused problems when used with multiple inheritance.

This commit fixes issue pytest-dev#265.
mfa pushed a commit to aexeagmbh/pytest-django that referenced this issue May 17, 2017
…ritance

pytest-django monkeypatches Django's setUpClass / tearDownClass to call
them at the correct time during fixture setup/teardown. The previous
implementation caused problems when used with multiple inheritance.

This commit fixes issue pytest-dev#265.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants