Skip to content

unable to avoid duplicate tests when combining addopts and positional arguments using setup.cfg #1311

@foxx

Description

@foxx

This is extended from #1187.

In my case there is some surprising behaviour. If I run the test suite using addopts from setup.cfg then the tests are duplicated and detected twice. However if I run it using addopts from pytest.ini, then the problem goes away, which is very strange.

After using --debug, I can see that the arguments are actually duplicated when using setup.cfg;

args=['-rw', '-vv', '--maxfail=1', '--cov=bottlecap.py', '--showlocals', '--doctest-modules',
 '--cov-report=term-missing', '--trace-config', '--debug', 'tests', '-rw', '-vv', '--maxfail=1', 
'--cov=bottlecap.py', '--showlocals', '--doctest-modules', '--cov-report=term-missing',
 '--trace-config', '--debug', 'tests']

There are also issues with using setup.cfg, for example passing in testpaths results in an error;

$ python setup.py test
running pytest
error: error in setup.cfg: command 'PyTest' has no such option 'testpaths'

There is a comment by a maintainer usage of setup.cfg should be deprecated. All of the problems mentioned above seem to go away if I use pytest.ini, and there doesn't appear to be any clear advantage of trying to use setup.cfg for this.

Another option is to make [pytest] section of setup.cfg work exactly the same as if it was in pytest.ini, but I'm not sure how feasible that is. Alternatively, dropping support for that section in setup.cfg might be another option.

Thoughts @RonnyPfannschmidt / @nicoddemus ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions