40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
Changing standard (Python) test discovery
|
|
===============================================
|
|
|
|
changing directory recursion
|
|
-----------------------------------------------------
|
|
|
|
You can set the :confval:`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 :confval:`addopts` option you can make
|
|
this change more permanently::
|
|
|
|
# content of setup.cfg or tox.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 collectonly.py
|
|
<Module 'collectonly.py'>
|
|
<Function 'test_function'>
|
|
<Class 'TestClass'>
|
|
<Instance '()'>
|
|
<Function 'test_method'>
|
|
<Function 'test_anothermethod'>
|