Table Of Contents

Previous topic

simple hook using patterns

Next topic

mysetup pattern: application specific test fixtures

This Page

Changing standard (Python) test discovery

changing directory recursion

You can set the norecursedirs option in an ini-file, for example your setup.cfg in the project root directory:

# content of setup.cfg
[pytest]
norecursedirs = .svn _build tmp*

This would tell py.test to not recurse into typical subversion or sphinx-build directories or into any tmp prefixed directory.

always try to interpret arguments as Python packages

You can use the --pyargs option to make py.test try interpreting arguments as python package names, deriving their file system path and then running the test. Through an ini-file and the addopts option you can make this change more permanently:

# content of pytest.ini
[pytest]
addopts = --pyargs

finding out what is collected

You can always peek at the collection tree without running tests like this:

. $ py.test --collectonly pythoncollection.py
<Module 'pythoncollection.py'>
  <Function 'test_function'>
  <Class 'TestClass'>
    <Instance '()'>
      <Function 'test_method'>
      <Function 'test_anothermethod'>