How to ignore missing (non-existing) files/tests #13213
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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
@RonnyPfannschmidt, Why doesn't --continue-on-collection-errors
Force test execution even if collection errors occur``` |
Beta Was this translation helpful? Give feedback.
-
@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:
|
Beta Was this translation helpful? Give feedback.
-
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.args
beforepytest_collect
is 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-errors
doesn't help here. The error is still raised, and pytest doesn't execute resolved tests.pytest_collection
and just errors out.try...except
inside the hook doesn't even get into theexcept
block.pytest_exception_interact
also 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.py
contenttest-list-with-missing-file.txt
contentOutput
Beta Was this translation helpful? Give feedback.
All reactions