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.

Notification about missing python test suite on non-python projects

See original GitHub issue

Environment data

  • VS Code version: 1.51.1
  • Extension version: v2020.11.371526539
  • OS and version: macOS 10.15.7 (19H2) | Darwin x64 19.6.0
  • Python version: 3.8.5
  • Type of virtual environment used: venv
  • Value of the python.languageServer setting: Pylance

Expected behaviour

If I open a project that doesn’t have any python file, I shouldn’t be getting any annoying popup about pytest not being installed, as it’s not relevant at all. Even for python project seems a bit annoying to get this toast notifications, but I believe this should be addressed at vs code level

Actual behaviour

Opening a project that doesn’t have any python file results in a toast notification prompting to install pytest Screenshot 2020-11-28 at 21 27 02 Screenshot 2020-11-28 at 21 26 02

Steps to reproduce:

  1. Have the "python.testing.pytestEnabled": true setting
  2. Open any non python project (or python projects without pytest installed)

Logs

Output for Python in the Output panel

Starting Pylance language server.
Python interpreter path: /usr/local/bin/python3
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/Projects/smth -s --cache-clear
cwd: ~/Projects/smth
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/Projects/smth -s --cache-clear
cwd: ~/Projects/smth
> conda --version
Error 2020-11-28 21:25:45: Failed to parse discovered Test r [Error]: Traceback (most recent call last):
  File "/Users/alexviscreanu/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "/Users/alexviscreanu/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
    from . import pytest, report
  File "/Users/alexviscreanu/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
    from ._discovery import discover
  File "/Users/alexviscreanu/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

    at ChildProcess.<anonymous> (/Users/alexviscreanu/.vscode/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:9:456869)
    at Object.onceWrapper (events.js:313:26)
    at ChildProcess.emit (events.js:223:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:223:5)
    at Socket.EventEmitter.emit (domain.js:475:20)
    at Pipe.<anonymous> (net.js:664:12)
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pytest"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
karthiknadigcommented, Mar 19, 2021

@aexvir I created #15729 to track that request.

0reactions
aexvircommented, Mar 19, 2021

Oh, nice catch, thanks for linking it 🙂️

although this will still mean popping up this notification when opening any python project… so the suggestion for only showing it once still sounds reasonable to me

will there be a follow up issue to this one for adding the “do not show again” button then? or this isn’t something that you want to change?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detect missing unittests - python - Stack Overflow
I am refactoring a legacy Python project, which did not have any unittests. Assuming a directory structure like this: C:. ├───scripts │ ...
Read more >
unittest — Unit testing framework — Python 3.11.1 ...
It checks for a specific response to a particular set of inputs. unittest provides a base class, TestCase , which may be used...
Read more >
Knowledge Bits — Common Python Packaging Mistakes
An overview of common mistakes made in creating & building a Python package and how to avoid them.
Read more >
pytest Documentation - Read the Docs
pytest discovers all tests following its Conventions for Python test discovery, so it finds both test_ prefixed functions.
Read more >
Using the test suite - BuildStream documentation
Some of BuildStream's dependencies have non-python build dependencies. When running tests with tox , you will first need to install these dependencies.
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