-
pytest is wonderful, thanks to all. I just have a small question: is there any way of identifying, in the context of tests, the project root directory, by which I mean the directory with the src and tests directories? The problem being that you can run Incidentally, in order to exclude a directory under my root directory from test discovery searching, I found that I had to put a pytest.ini in that root directory... which then also seemed to alter the location of the CWD (always making it the root directory). So it can be a bit of a rigmarole to find where the root directory may actually be in relation to the CWD, and I just wonder whether there's a simple way of obtaining that root directory path. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You should get the |
Beta Was this translation helpful? Give feedback.
You should get the
pytestconfig
fixture, then it'spytestconfig.rootpath
(it's apathlib.Path
instance). This returns therootdir
.