Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR collecting setup.py while trying to run py.test?

I am trying to run py.test on my package but it is trying to parse setup.py from the project root directory even if I tried to exclude it.

I need to collect the tests from *.py files because the test classes are included in the modules.

# setup.cfg
[pytest]
norecursedirs = .svn _build tmp* lib/third lib *.egg bin distutils setup.py
python_files = *.py

Still when I run py.test it will give me ERROR collecting setup.py which I already excluded.

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/core.py:140: in setup
>           raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
E           SystemExit: usage: py.test [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
E              or: py.test --help [cmd1 cmd2 ...]
E              or: py.test --help-commands
E              or: py.test cmd --help
E           
E           error: no commands supplied
like image 329
sorin Avatar asked May 29 '12 17:05

sorin


2 Answers

You can configure the --ignore option to your pytest.ini configuration like this maybe:

addopts = --ignore=setup.py

which should help if you are in the root directory and want py.test to ignore the setup.py file.

like image 128
hpk42 Avatar answered Oct 01 '22 03:10

hpk42


From the docs (and the name of the variable) it looks like norecursedirs only skips directories, so since setup.py is a file, putting it in norecursedirs has no effect.

http://pytest.org/latest/customize.html?highlight=norecursedirs#confval-norecursedirs

like image 23
glyphobet Avatar answered Oct 01 '22 04:10

glyphobet