Am 25.06.2010 10:55, schrieb holger krekel: >> There is just one little thing left where i'm not sure what the benefit >> is in it. Consider the dir structure as meant in the last mails: >> >> a/conftest.py >> b/conftest.py >> >> If py.test is started from within the "a"-directory not only the >> conftest.py's of parent directories of "a" are loaded (as stated in the >> docs), also the conftest.py of the "b"-directory is loaded. I >> intuitively wouldn't consider "b" a parent of "a". Also the tests from >> "b" are not run of course. Does it makes sense to load "b"'s conftest.py >> too in this situation? > > I agree it's a bit suprising. I'll explain why also to clarify it for myself > :) > > * py.test sees the command line arg b/test_hello.py > * it performs collection starting from the directory where 'b' is contained, > call it ROOTDIR > * collecting ROOTDIR will collect all matching subdirs and files, so 'a' and > 'b' > * [HERE] collecting the 'b' subdir will consult b/conftest.py to allow it to > influence the > directory collection objects (it will call the > pytest_collect_directory(...) hook to be precise) > * after all subdirs/files have been collected the one matching the name 'b' > is dived into > * ...
This process I was expecting when calling "py.test" (without arguments or with 'b/test_hello.py') from the ROOTDIR, as i think in your explaination you meant having py.test being called from ROOTDIR because the argument 'b/test_hello.py' you mentioned has 'b/' in it, right?. When calling py.test (without arguments or 'test_hello.py') from within the 'b'-directory i would expect that the collecting will only be done for that 'b'-directory and its child directories. To make sure we are talking about the same a's and b's ;) the dir structure is: ~/ROOTDIR/ a/ conftest.py test_hello.py b/ contest.py test_hello.py on the cmd line i do: ~$ cd ROOTDIR/b ~/ROOTDIR/b$ py.test ================ test session starts ================ platform linux2 -- Python 2.5.5 -- pytest-1.3.1 test object 1: ~/ROOTDIR/b test_hello.py . ============= 1 passed in 0.01 seconds ============== if both conftest.py's have a pytest_configure and pytest_unconfigure, they will be called in this order: configure of b configure of a unconfigure of a unconfigure of b I agree that both 'a' and 'b' should be inspected when calling py.test from ROOTDIR, but when calling it within 'a' or 'b'...? ...i hope i don't bother you if i misunderstood your explaination (sorry in that case). but that you wrote "* py.test sees the command line arg b/test_hello.py" made me wonder whether you misunderstood me in the way that you thought i meant calling py.test from ROOTDIR. Thank you, Best regards, Frank _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev