Repository navigation
How to ignore missing (non-existing) files/tests #13213
Unanswered
sashko1988
asked this question in
Q&A
Replies: 4 comments 12 replies
|
It'd be nice to have some example repository as a demo, simulating this situation.. I don't understand how you invoke |
1 reply
|
This one is tricky We must fail the cli for missing tests that where explicitly passed Having a soft version of that ought to be a plugin that would warn/xfail gor missing tests instead of failing instantly |
3 replies
|
@RonnyPfannschmidt, Why doesn't |
2 replies
|
@RonnyPfannschmidt, Regarding plugin route What I tried, and it doesn't work as expected:This is the part of my @pytest.hookimpl(wrapper=True)
def pytest_collection(session):
# clear session args if they only contain the current working directory,
# so pytest won't try to traverse it
clear_session_args(session)
# resolve tests from files
resolve_tests_from_files(session)
# perform collection from session args if they are not empty
return (yield)Dumb one:
Bulk approach:
I didn't check the behavior in
Questions:
|
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have an external system to store test suites. If simplified, it is akin to a testlist file — test nodes are resolved and passed into session.
config.argsbeforepytest_collectis executed.Sometimes, testlists get out of sync with repo content - i.e. files deleted, test classes/test functions removed from modules, but they remain in the testlists.
Pytest raises an error whenever a file, function, or class is not found.
--continue-on-collection-errorsdoesn't help here. The error is still raised, and pytest doesn't execute resolved tests.pytest_collectionand just errors out.try...exceptinside the hook doesn't even get into theexceptblock.pytest_exception_interactalso isn't called.pytest_pycollect_makeitem.I have an idea for a workaround: check if the file path and class/function exist before starting
pytest_collect. But it doesn't feel right because it essentially duplicates what pytest does during the collection phase.What do you think is the best approach to ignore missing tests?
Reproduce:
Repo with a simple reproduction https://github.com/sashko1988/pytest-how-to-ignore-missing
Example:
Folder structure:
tests/test_example.pycontenttest-list-with-missing-file.txtcontentOutput
All reactions