Skip to content

Many pytest options fails when running specific tests #1070

@pslacerda

Description

@pslacerda

I use the pytest-sugar to prettify my tests but need to disable it to have a more standard output to have full file paths instead of coloured shortened ones. This need the -p no:sugar option to be given.

Also many other options need arguments because aren't simple flags, like -c config.file.

When running a specifc test (e.g. clicking in "Run test" or "Debug test" above test definition), the settings.unitTest.pyTestArgs is filtered to remove any argument that doesn't starts with a -, which fails when running options like -p or -c.

The only ways I figure out to work around this is:

  • Remove this filter. Not wanted, because would force users to have a setup.cfg or something like it;
  • Hardcode all pytest options;
  • Separate the positional file_or_dir argument from the rest. E.g. pyTestFilesOrDirs from pyTestArgs. This is my personal choice.

I would submit a pull requests, but the contributing guide says to open a issue first.

Environment data

  • VS Code version: 1.20.1
  • Extension version 2018.2.1 and master
  • OS and version: Fedora 27
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: pytest

Actual behavior

Simply put, many pytest options aren't supported when running specific tests

Expected behavior

To run the test suite.

Steps to reproduce:

  1. Use the following setting:
{
    "python.unitTest.pyTestArgs": ["-p", "no:sugar"]
}
  1. Click on "Debug test".

Logs

Output for the Python Test Log.

usage: pytest.py [options] [file_or_dir] [file_or_dir] [...]
pytest.py: error: argument -p: expected one argument

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions