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.

No code lenses shown for pytest

See original GitHub issue

Visual Studio Code - Insiders: 1.36.0-insider python-insider: 2019.6.21464-rc

Repro steps:

  1. Input below code:
def test_passing():
    assert 42 == 42
def test_failure():
    assert 42 == -13
  1. Run tests with pytest framework
  2. Run all tests

Actual Result: No code lenses shown after run all tests image

Expect Result: It should display code lenses

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
korn-1c-rucommented, Jul 2, 2019

I’ve resolved this issue (codelens is visible now) by renaming first letter of the first dir in the workspace path to lowercase. It was sole uppercase letter in the path. But it was uppercase all its lifetime and I had no problems with codelens and debug. Don’t forget to remove cache folders (.pytest_cache, __pycache__).

Is it relevant to Microsoft/vscode#12448?

1reaction
ericsnowcurrentlycommented, Jul 31, 2019

FWIW, the adapter effectively [1] returns whatever pytest gives it. We have no guarantees about casing or even that the returned root and test source will be in the workspace. So we should always match carefully, as much as possible. What pytest provides will almost always be okay, but the mitigation is worth doing anyway (not big nor complicated).

[1] Currently we normcase but the situation remains either way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment Data - Stack Overflow
Typically the code lenses for tests fail because either another extension interferes (e.g. gitlens) or the code isn't being picked up by ...
Read more >
11 Best VS Code extensions for Python (2022)
This list contains the 10 best VS Code extensions for Python including Pylance, Sourcery, Python by Microsoft, and more.
Read more >
How and why I use pytest's xfail - Paul Ganssle
Although I was initially skeptical, several years ago I was convinced that xfail is a quite useful tool for managing an evolving codebase....
Read more >
Python Test Explorer (Django Hacked) - Visual Studio Marketplace
Extension for Visual Studio Code - Run your Django unittest tests in the Sidebar of ... As of now, there are no way...
Read more >
pytest vs Lens comparison of testing frameworks - Knapsack Pro
Lens is a unit-testing framework for PHP that needs no assertions ... Client-side. Allows testing code execution on the client, such as a...
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