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

Add an option to ignore unknown dependencies #10

Closed
somnambWl opened this issue Aug 23, 2017 · 2 comments
Closed

Add an option to ignore unknown dependencies #10

somnambWl opened this issue Aug 23, 2017 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@somnambWl
Copy link

Is there an option to disable dependencies? f.e by some parser option?
If someone wants to run f.e. a test suite, but this one will be dependent on some test from different test suite, tests will be skipped.
If there will be a lot of tests and they will be heavily dependent, then these dependencies saves a lot of time if tests are run all, but they are contraproductive while only part of the tests are to be run (one has to open a file and comment dependencies).

@RKrahl
Copy link
Owner

RKrahl commented Aug 27, 2017

No, currently there is no such option. To be honest, I don't know how such an option should look like.

If I understand you correctly, you have a large test suite and you only want to run a subset of the tests. But some of the selected tests depend on other tests that are not in the selection, so these tests get skipped, because their dependencies have not been run. What I could imagine would be to add a global option ignore_unknown_dependency. If set to False, the default, a test will be skipped unless all the dependencies have been run successful. This is the current behavior. But if this option is set to True, a test will be skipped if any of the dependencies has been skipped or failed. E.g. this would ignore any dependencies that have not been run at all. Would that suit your use case?

@RKrahl RKrahl added the enhancement New feature or request label Aug 27, 2017
@somnambWl
Copy link
Author

Yes, you understood correctly, the subset of tests is skipped, because it's dependencies have not been run at all.

That option is exactly what would solve this.

If False test is run if:

  • All dependencies have been run
  • All dependencies have been run successfully

If True test is run if:

  • Dependencies that have been run were successful.

Dependencies that are not recognized and have not been run at all are ignored.

I will add an example. If I have this code:

import pytest
import pytest_dependency

def test_AAA():
    assert 0

@pytest.mark.dependency(depends=["test_AAA"])
def test_BBB1():
    pass

@pytest.mark.dependency(depends=["test_BBB1"])
def test_BBB2():
    pass

For pytest -v everything works great and output is:

test_basics.py::test_AAA FAILED
test_basics.py::test_BBB1 SKIPPED
test_basics.py::test_BBB2 SKIPPED

For pytest -v -k BBB is output:

test_basics.py::test_BBB1 SKIPPED
test_basics.py::test_BBB2 SKIPPED

But test_BBB1 is skipped only because test_AAA have not been run at all.
With an option it may look like this: pytest -v -k BBB -ignore_unknown_dependency True gives:

test_basics.py::test_BBB1 PASSED
test_basics.py::test_BBB2 PASSED

Dependency on test_AAA is ignored because it has not been run and all tests passed

@RKrahl RKrahl changed the title Option to disable dependencies Add an option to ignore unknown dependencies Aug 28, 2017
@RKrahl RKrahl added this to the 0.3 milestone Aug 28, 2017
@RKrahl RKrahl closed this as completed in 67fa9ee Dec 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants