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

Support pytest version >= 4.1 #18

Closed
kondratyev-nv opened this issue Jan 9, 2019 · 8 comments
Closed

Support pytest version >= 4.1 #18

kondratyev-nv opened this issue Jan 9, 2019 · 8 comments

Comments

@kondratyev-nv
Copy link

pytest-describe plugin is not working with pytest 4.0 or later.

=========================================== ERRORS ============================================
_______________ ERROR collecting test/test_samples/pytest/test/describe_test.py _______________
.tox/py27/local/lib/python2.7/site-packages/pytest_describe/plugin.py:110: in _getobj
    return self._importtestmodule()
.tox/py27/local/lib/python2.7/site-packages/pytest_describe/plugin.py:119: in _importtestmodule
    copy_markinfo(module, self.funcobj)
.tox/py27/local/lib/python2.7/site-packages/pytest_describe/plugin.py:60: in copy_markinfo
    from _pytest.mark import MarkInfo
E   ImportError: cannot import name MarkInfo
!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================== 1 error in 0.75 seconds ===================================

This error appears for the test from sample

import pytest


def describe_list():

    @pytest.fixture
    def list():
        return []

    def describe_append():

        def adds_to_end_of_list_passed(list):
            list.append('foo')
            list.append('bar')
            assert list == ['foo', 'bar']

    def describe_remove():

        @pytest.fixture
        def list():
            return ['foo', 'bar']

        def removes_item_from_list_passed(list):
            list.remove('foo')
            assert list == ['bar']

It looks like this happens due to changes in mark API since version 4.0, for example, see https://github.com/pytest-dev/pytest/blob/master/doc/en/deprecations.rst#somefunctionmarkname.

@ropez
Copy link
Collaborator

ropez commented Jan 9, 2019

This looks like it might require some work. Is there any chance you can look into this, and make a PR?

@Pankejk
Copy link

Pankejk commented Jan 10, 2019

I like this plugin and I have the same issue. +1

@kondratyev-nv
Copy link
Author

@ropez I have tried to run tests with various versions, and it looks like no main code changes needed for newer python versions and pytest up to 4.0.2. I think of making a PR on this at least.

As for the upper pytest versions, I'll take a look.

@ropez
Copy link
Collaborator

ropez commented Jan 16, 2019

Sorry, I haven't had time to look into this. Are you saying that the issue with importing MarkInfo was not a problem after all?

@kondratyev-nv
Copy link
Author

@ropez This is the problem for pytest >= 4.1. Everything is fine with the previous versions, and I have added a couple of tests to be sure. Please see PR #19.

@kondratyev-nv kondratyev-nv changed the title Support pytest version >= 4.0 Support pytest version >= 4.1 Jan 16, 2019
@ropez
Copy link
Collaborator

ropez commented Jan 16, 2019

Right, I was a little bit confused because you wrote "4.0 or later" in the original post. I will see if I find some time to look for a solution for 4.1 then.

@kondratyev-nv
Copy link
Author

@ropez It looks like I have a working solution. However, the tests are failing with the latest pytest version due to the bug in pytest pytest-dev/pytest#4649. I'll open a PR with the fix after the next pytest patch will be released.

@ropez
Copy link
Collaborator

ropez commented Jan 24, 2019

@kondratyev-nv Maybe we should just change -k to -m in those test. I don't remember exactly, but it may well be that I should have used -m in the first place, and it just happened to work, like the comments in the pytest issue suggest.

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

No branches or pull requests

3 participants