question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding --cov-fail-under=100 on adopts config will provoque discovery failure when coverage under 100%

See original GitHub issue

Environment data

  • VS Code version: 1.45.1
  • Extension version (available under the Extensions sidebar): 2020.5.80290
  • OS and version: macOS 10.15.4
  • Python version (& distribution if applicable, e.g. Anaconda): homebrew 3.7.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Relevant/affected Python packages and their versions: pytest 5.4.1, coverage 5.1
  • Relevant/affected Python-related VS Code extensions and their versions: vscode-python 2020.5.80290
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): Enabled
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

Tests are discovered

Actual behaviour

Error message is shown with:

Test discovery error, please check the configuration settings for the tests.

Steps to reproduce:

file: test_simple.py

def test():
    return 43


def test2():
    return 55


def test_thetest():
    assert test() == 43


# def test_thetest2():
#     assert test2() == 55

Running this code with pytest should result in 75% code coverage (4 statements, 3 covered).

  1. run: pytest test_simple.py

Logs

FAIL Required test coverage of 100% not reached. Total coverage: 75.00% ============================ no tests ran in 0.65s =============================

Traceback (most recent call last): File “~/.vscode/extensions/ms-python.python-2020.5.80290/pythonFiles/testing_tools/run_adapter.py”, line 22, in <module> main(tool, cmd, subargs, toolargs) File “~/.vscode/extensions/ms-python.python-2020.5.80290/pythonFiles/testing_tools/adapter/main.py”, line 100, in main parents, result = run(toolargs, **subargs) File “~/.vscode/extensions/ms-python.python-2020.5.80290/pythonFiles/testing_tools/adapter/pytest/_discovery.py”, line 44, in discover raise Exception(“pytest discovery failed (exit code {})”.format(ec)) Exception: pytest discovery failed (exit code 1)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
kimadelinecommented, May 4, 2021

Same as https://github.com/microsoft/vscode-python/pull/15978#issuecomment-832262760: After discussing it with the team, we do not want to add --no-cov to the default list of arguments as we want to keep our list of defaults short, and let users configure the tools as they need, either by updating the setting globally, or using configuration files for the tools directly.

0reactions
n4nn31355commented, May 3, 2021

Adding --no-cov in python.testing.pytestArgs setting helps to avoid this behavior. If it’s acceptable I can do it in the same way as in https://github.com/microsoft/vscode-python/pull/15978

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration — pytest-cov 4.0.0 documentation
This plugin provides a clean minimal set of command line options that are added to pytest. For further control of coverage use a...
Read more >
pytest-cov - Read the Docs
Mostly useful for scripts and configuration files. --cov-fail-under=MIN Fail if the total coverage is less than MIN. --cov-append.
Read more >
Getting a Django Application to 100% Test Coverage
Code coverage is a simple tool for checking which lines of your application code are run by your test suite. 100% coverage is...
Read more >
How to Obtain 100% Structural Code Coverage of Safety ...
Many software development and verification engineers don't truly understand why obtaining structural coverage is important.
Read more >
Code coverage using pytest and codecov.io
Failing the tests if coverage is below a certain threshold ; Run tests run ; | pytest --cov-fail-under=100 --cov asgi_csrf ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found