1
votes

I'm having trouble getting the VS Code PyTest code runner to work the way I'd like. It seems pytest options may be an all-or-nothing situation.

Is there any way to run different sets of PyTest options easily in the VS Code interface?

For example:

  1. By default, run all tests not marked with @pytest.mark.slow.

    • This can be done with the argument -m "not slow"
    • But, if I put that in a pytest.ini file, then it will never run any tests marked slow, even if I pick that particular test in the interface and try to run it. The resulting output is collected 1 item... 1 item deselected.
  2. Run sometimes with coverage enabled, and sometimes without.

The only way I can see to do this is to run PyTest from the command line, which then loses the benefit of auto-discovery, running/debugging individual tests from the in-line interface, etc.

What am I missing?

Note: Currently using VS Code 1.45.1, Python 3.7.6, and PyTest 5.3.5

1
I logged an enhancement request in the vscode-python repo on github for anyone interested. If you like the idea, please vote on it.LightCC

1 Answers

3
votes

You're not missing anything. There currently isn't a way to provide per-execution arguments to get the integration you want with the Test Explorer.