py.test - How do I get a pythonic list of all the pytest tests in a folder? -
something --collect, python , not cmd, returns list of paths. tried see how pytest , can't seem ro find it.
thanks!
all collected tests stored attribute items of session. can access session object by
- session level
fixture - pytest plugins, example:
pytest_runtestlooporpytest_sessionstart
example:
@pytest.fixture(scope='session', autouse=true) def get_all_tests(request): items = request.session.items all_tests_names = [item.name item in items] all_tests_locations = [item.location item in items] # location tuple of (file_path, linenumber, classname.methodname) if want more info object session or item, of cause can read docs or source code, prefer use pdb.set_trace dig object.
Comments
Post a Comment