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

Dependency is skipped when I rename test within dependency. #47

Closed
piotr-lesniak opened this issue Nov 5, 2020 · 1 comment
Closed
Labels
support Issue induced by the requester not fully understanding the software rather then by a misbehavior

Comments

@piotr-lesniak
Copy link

2 files:

test_abc.py

import pytest


class TestAbc:
    @pytest.mark.dependency()
    def test_abc(self):
        assert False

and test_def.py:

import pytest


class TestDef:
    @pytest.mark.dependency(depends=['test_abc.py::TestAbc::test_abc'], scope='package')
    def test_def(self):
        pass

It works as expected now: test_abc fails, test_def is skipped.

When I rename test_def within dependency like this:

import pytest


class TestDef:
    @pytest.mark.dependency(depends=['test_abc.py::TestAbc::test_abc'], scope='package')
    @pytest.mark.dependency(name='test_two')
    def test_def(self):
        pass

actual behaviour is: test_abc fails, test_def passes - is that correct behaviour? Shouldn't test_def be skipped?

@RKrahl
Copy link
Owner

RKrahl commented Nov 8, 2020

No. With pytest, you cannot apply the same marker twice to the same test. If you try to do so, the second instance of the marker will override the first one. So what your second version of test_def.py essentially does is:

import pytest

class TestDef:
    @pytest.mark.dependency(name='test_two')
    def test_def(self):
        pass

What you probably wanted to do is:

import pytest

class TestDef:
   @pytest.mark.dependency(name='test_two', depends=['test_abc.py::TestAbc::test_abc'], scope='package')
    def test_def(self):
        pass

@RKrahl RKrahl added the invalid This doesn't seem right label Dec 25, 2020
@RKrahl RKrahl closed this as completed Dec 25, 2020
@RKrahl RKrahl added support Issue induced by the requester not fully understanding the software rather then by a misbehavior and removed invalid This doesn't seem right labels Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Issue induced by the requester not fully understanding the software rather then by a misbehavior
Projects
None yet
Development

No branches or pull requests

2 participants