Skip to content

Commit

Permalink
Fix regression introduced in 96f5fb1.
Browse files Browse the repository at this point in the history
The previous fix did not properly check the full MRO chain when looking
for the super method, which then failed when used with mixins that does
not define setUpClass/tearDownClass.

This commit fixes issue #280.
  • Loading branch information
pelme committed Oct 6, 2015
1 parent 7825837 commit 1bf4920
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ def pytest_configure():


def _method_is_defined_at_leaf(cls, method_name):
return getattr(cls.__base__, method_name).__func__ is not getattr(cls, method_name).__func__
super_method = None

for base_cls in cls.__bases__:
if hasattr(base_cls, method_name):
super_method = getattr(base_cls, method_name)

assert super_method is not None, '%s could not be found in base class' % method_name

return getattr(cls, method_name).__func__ is not super_method.__func__


_disabled_classmethods = {}
Expand Down
8 changes: 7 additions & 1 deletion tests/test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ def test_multi_inheritance_setUpClass(self, django_testdir):
from django.test import TestCase
from .app.models import Item
class TestA(TestCase):
# Using a mixin is a regression test, see #280 for more details:
# https://github.com/pytest-dev/pytest-django/issues/280
class SomeMixin(object):
pass
class TestA(SomeMixin, TestCase):
expected_state = ['A']
state = []
Expand Down

0 comments on commit 1bf4920

Please sign in to comment.