The bad news is that the situation with sessionstart / configure is not well indicated. Sessionstart, in particular, is not well documented, because the semantics are different if it is in the case of xdist / distribution or not. You can distinguish between these situations, but all this is too complicated.
The good news is that pytest-2.3 should ease the situation. If you define the @setup function (soon to be renamed to @fixture) with scope = "session", you can implement a tool that is called once for each process in which the test is running. For distributed testing, this means once for each slave. For uniprocessor testing, this means once for the entire test run. In any case, if you execute "-collectonly" or "-h" or other parameters that are not related to running the tests, then the binding functions are not performed at all.
Hope this clarifies.
hpk42 source share