Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many pytest options fails when running specific tests #1070

Closed
pslacerda opened this issue Mar 14, 2018 · 2 comments · Fixed by #1917
Closed

Many pytest options fails when running specific tests #1070

pslacerda opened this issue Mar 14, 2018 · 2 comments · Fixed by #1917
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@pslacerda
Copy link

pslacerda commented Mar 14, 2018

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
@pslacerda
Copy link
Author

pslacerda commented Mar 14, 2018

Yet another possibility is to parse the output of pytest --help to identify options that receive an argument, is pretty standard. For instance the ' (--[a-z0-9-]+)=[^ ]+' regex for long options and ' (-[a-z0-9-]+) [^ ]+' for short ones.

It is also somewhat safe like the third possibility I said before.

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug needs verification area-testing and removed needs verification labels Mar 15, 2018
@brettcannon brettcannon added this to the May 2018 milestone May 7, 2018
@DonJayamanne DonJayamanne removed this from the May 2018 milestone May 31, 2018
@DonJayamanne DonJayamanne self-assigned this May 31, 2018
@brettcannon brettcannon added this to the June 2018 milestone Jun 5, 2018
@brettcannon brettcannon added the P0 label Jun 14, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants