Skip to content

Unable to run coverage #24166

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

Closed
deepak1556 opened this issue Sep 24, 2024 · 4 comments
Closed

Unable to run coverage #24166

deepak1556 opened this issue Sep 24, 2024 · 4 comments
Assignees
Labels
area-testing triage-needed Needs assignment to the proper sub-team

Comments

@deepak1556
Copy link

deepak1556 commented Sep 24, 2024

Testing #24160

Python extension - v2024.15.2024092301 (pre-release)

Coverage is enabled, adding branch coverage as an argument.
Running pytest with args: ['-p', 'vscode_pytest', '--rootdir=/Users/demohan/github/inc_dec_example_repo', '--cov=.', '--cov-branch', '/Users/demohan/github/inc_dec_example_repo/inc_dec_example_test_suite/test_two_classes.py::ClassA::test_a1', '/Users/demohan/github/inc_dec_example_repo/inc_dec_example_test_suite/test_two_classes.py::ClassA::test_a2', '/Users/demohan/github/inc_dec_example_repo/inc_dec_example_test_suite/test_two_classes.py::ClassB::test_b1', '/Users/demohan/github/inc_dec_example_repo/inc_dec_example_test_suite/test_two_classes.py::ClassB::test_b2']
ERROR: usage: run_pytest_script.py [options] [file_or_dir] [file_or_dir] [...]
run_pytest_script.py: error: unrecognized arguments: --cov=. --cov-branch
  inifile: None
  rootdir: /Users/demohan/github/inc_dec_example_repo
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Sep 24, 2024
@eleanorjboyd
Copy link
Member

Hi! Did you install pytest-cov? This is usually the reason why this error appears, thanks!

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Sep 24, 2024
@deepak1556
Copy link
Author

Ah yeah there was an error about missing pytest in unittest discovery, so installed the following two packages in a fresh environment.

python -m pip install pytest
python -m pip install coverage

Error:

Failed to import test module: test_wait_parameterized
Traceback (most recent call last):
  File "/Applications/Xcode-beta.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/Applications/Xcode-beta.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/Users/demohan/github/inc_dec_example_repo/inc_dec_example_test_suite/test_wait_parameterized.py", line 1, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

.vscode/settings.json only had unittest configured

{
  "python.testing.pytestArgs": ["."],
  "python.testing.unittestEnabled": true,
  "python.testing.pytestEnabled": false,
  "python.testing.unittestArgs": [
    "-v",
    "-s",
    "./inc_dec_example_test_suite",
    "-p",
    "test_*.py"
  ]
}

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Sep 25, 2024
@deepak1556
Copy link
Author

deepak1556 commented Sep 25, 2024

Maybe the confusion here was the test explorer shouldn't bring in tests that have pytest in them when configured only for unittests ?
Screenshot 2024-09-25 at 9 25 42

@eleanorjboyd
Copy link
Member

yes this is an existing bug here: #23234 sorry about hitting that!

@eleanorjboyd eleanorjboyd closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-testing triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants