astropy/astropy — pull request #77 by jiffyclub (2011-11-23 04:04:11+00:00)
Title: Put py.test plugins in root level conftest.py file

One way to have the same py.test behavior for `astropy.test` and `py.test` at the command line is to place our plugins in a `conftest.py` file. py.test searches for a `conftest.py` in its invoking directory or anywhere directly above that directory and uses any hooks it finds in the file. This works both when calling `py.test` directly at the command line or when invoking it using `pytest.main` as the test helper does. This pull request is a working sample of how that would look.

Looking at the py.test documentation (http://pytest.org/latest/plugins.html#conftest-py-local-per-directory-plugins) it even looks like py.test will discover more than one `conftest.py` file and respect them all, though who knows in what order. This means it would be possible to have a local level `conftest.py` that defines some local test setup hooks and the one at the root level should still be found and used. I haven't tested this, though.