Skip to content

Upgrade requirements #484

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

Merged
merged 2 commits into from
Jun 24, 2018
Merged

Upgrade requirements #484

merged 2 commits into from
Jun 24, 2018

Conversation

adamchainz
Copy link
Owner

No description provided.

@adamchainz
Copy link
Owner Author

Seeing this failure:

 ERROR at setup of SlowFixDatetimeColumnsTests.test_with_one_column_to_migrate _
request = <SubRequest '_django_setup_unittest' for <TestCaseFunction 'test_with_one_column_to_migrate'>>
django_db_blocker = <pytest_django.plugin._DatabaseBlocker object at 0x7f47fca02bd0>
    @pytest.fixture(autouse=True, scope='class')
    def _django_setup_unittest(request, django_db_blocker):
        """Setup a django unittest, internal to pytest-django."""
        if django_settings_is_configured() and is_django_unittest(request):
            getfixturevalue(request, 'django_test_environment')
            getfixturevalue(request, 'django_db_setup')
    
            django_db_blocker.unblock()
    
            cls = request.node.cls
    
            # implement missing (as of 1.10) debug() method for django's TestCase
            # see pytest-dev/pytest-django#406
            def _cleaning_debug(self):
                testMethod = getattr(self, self._testMethodName)
                skipped = (
                    getattr(self.__class__, "__unittest_skip__", False) or
                    getattr(testMethod, "__unittest_skip__", False))
    
                if not skipped:
                    self._pre_setup()
                super(cls, self).debug()
                if not skipped:
                    self._post_teardown()
    
            cls.debug = _cleaning_debug
    
            _restore_class_methods(cls)
>           cls.setUpClass()
E           TypeError: 'NoneType' object is not callable
.tox/py27-django18/local/lib/python2.7/site-packages/pytest_django/plugin.py:422: TypeError
 ERROR at setup of SlowFixDatetimeColumnsTests.test_with_two_columns_to_migrate 
item = <TestCaseFunction 'test_with_two_columns_to_migrate'>
    def pytest_runtest_setup(item):
        if django_settings_is_configured() and is_django_unittest(item):
            cls = item.cls
>           _disable_class_methods(cls)
.tox/py27-django18/local/lib/python2.7/site-packages/pytest_django/plugin.py:333: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py27-django18/local/lib/python2.7/site-packages/pytest_django/plugin.py:298: in _disable_class_methods
    _classmethod_is_defined_at_leaf(cls, 'setUpClass'),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cls = <class 'tests.testapp.management.commands.test_fix_datetime_columns.SlowFixDatetimeColumnsTests'>
method_name = 'setUpClass'
    def _classmethod_is_defined_at_leaf(cls, method_name):
        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)
    
        method = getattr(cls, method_name)
    
        try:
            f = method.__func__
        except AttributeError:
>           pytest.fail('%s.%s should be a classmethod' % (cls, method_name))
E           Failed: <class 'tests.testapp.management.commands.test_fix_datetime_columns.SlowFixDatetimeColumnsTests'>.setUpClass should be a classmethod

adamchainz added a commit to adamchainz/pytest-django that referenced this pull request Jun 17, 2018
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.
@adamchainz
Copy link
Owner Author

Awaiting pytest-dev/pytest-django#618

@adamchainz adamchainz merged commit c058d50 into master Jun 24, 2018
@adamchainz adamchainz deleted the upgrade_requirements branch June 24, 2018 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant