Hello,

I use in project who contain a setup.py and setup.cfg. I configured setup.py and setup.cfg to permit execution of tests with command "python setup.py test". Structure is following:

.
├── hello
│   └── __init__.py
├── setup.cfg
├── setup.py
└── tests
    ├── __init__.py
    ├── test_a.py
    └── test_b.py
setup.py is:

from setuptools import setup

setup(name='hello',
      version='0.1',
      description='hello',
      url='http://',
      author='hello',
      author_email='hello',
      license='MIT',
      packages=['hello'],
      setup_requires=['pytest-runner'],
      tests_require='pytest')
and setup.cfg is:

[aliases]
test=pytest

[tool:pytest]
addopts = tests
result of "python setup.py test" is:

running pytest
running egg_info
writing dependency_links to hello.egg-info/dependency_links.txt
writing top-level names to hello.egg-info/top_level.txt
writing hello.egg-info/PKG-INFO
reading manifest file 'hello.egg-info/SOURCES.txt'
writing manifest file 'hello.egg-info/SOURCES.txt'
running build_ext
============================ test session starts =============================
platform linux -- Python 3.5.3, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/bastien/Projects/test_pytest, inifile: setup.cfg
collected 2 items

tests/test_a.py .
tests/test_b.py .

========================== 2 passed in 0.02 seconds ==========================
But if i want to execute only test_b with "pytest tests/test_b.py::test_b":
============================ test session starts =============================
platform linux -- Python 3.5.3, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/bastien/Projects/test_pytest, inifile: setup.cfg
collected 3 items

tests/test_a.py .
tests/test_b.py ..

========================== 3 passed in 0.02 seconds ==========================
All tests are collected. setup.cfg (addopts part) is the fail. I need this "addopts" part because when some developpers who work on the project create a virtualenv inside the project, pytest search into the venv folder (i add "addopts = tests" to force pytest to check only "tests" folder).

How to conciliate them ? How keep a way to run test with "python setup.py test" and run a specific test with "pytest tests/test_b.py::test_b" ?

Thank's,
Bastien.

_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to