I'm following a book which tells me to use pytest.ini to declare test method markers.
I found that, in order to exclude a directory under the root (project) directory from test discovery searching I had to put a pytest.ini in that root directory.
When I run pytest from the root directory with no selective location regarding test discovery the markers are "found" from the pytest.ini.
But when I run pytest tests/func for example, I get "Unknown pytest.mark.xxx - is this a typo?" for all these marks.
If I cd to tests/func and go pytest, they are also not found, and I tend to imagine that pytest.ini in the root directory is not "seen" at all.
In fact experimentation shows that when I do pytest tests/func, pytest.ini is, similarly, just not being "seen".
At the moment my pytest.ini looks like this:
[pytest]
addopts = --ignore=source_dld
markers =
smoke: marks tests as smoke (deselect with '-m "not smoke"')
get: bubble
How can I make these marker declarations apply, and get my pytest.ini in the project root directory to be "seen", regardless of where the testing is happening?
Edit
There's a page in the docs about rootdir which I've tried to understand. In particular I note
--rootdir cannot be used with addopts inside pytest.ini because the rootdir is used to find pytest.ini already.
So I've tried this kind of thing:
...\py_lib2>pytest -rs --rootdir=. tests/func
...\py_lib2>pytest -rs --rootdir="D:\My documents\software projects\EclipseWorkspace\py_lib2" tests/func
... pytest.ini in the "project root" dir (py_lib2 here) still ignored. NB OS is W10.