Skip to content
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

No tests are being recognized within test files #83

Open
a3ng7n opened this issue Sep 10, 2024 · 8 comments
Open

No tests are being recognized within test files #83

a3ng7n opened this issue Sep 10, 2024 · 8 comments

Comments

@a3ng7n
Copy link

a3ng7n commented Sep 10, 2024

It seems no tests within files are being discovered - when running file, or running nearest, or debugging nearest the result is "No tests found" from neotest. The test file, however, does show up in the summary window, but shows a "skipped" icon next to it when run.
image

I created a fresh venv with python 3.12, and installed just pytest 8.3.3, and implemented their getting started:

# filename: test_sample.py
def func(x):
    return x + 1

def test_sample():
    assert func(3) == 5

class TestClass:
    def test_one(self):
        x = "this"
        assert "h" in x

    def test_two(self):
        x = "hello"
        assert hasattr(x, "check")

Running pytest yields the following, expected, output:
image

Here's my output of nvim -v:

% nvim -v
NVIM v0.11.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.1703358377
Run "nvim -V1 -v" for more info

And I'm running LazyVim - here's the lazy-lock.json lines for neotest:

  "neotest": { "branch": "master", "commit": "6d6ad113f56edc7c3f2a77a0836ea8c1b955ebea" },
  "neotest-python": { "branch": "master", "commit": "72603dfdbaad5695160268cb10531a14cc37236e" },

and the rest of my configuration is here: https://github.com/a3ng7n/nvim

@sergei1152
Copy link

+1 getting this too after upgrading my nvim/neotest/neotest-pytest. Can't quite figure out which upgrade caused the regression

@a3ng7n
Copy link
Author

a3ng7n commented Sep 14, 2024

+1 getting this too after upgrading my nvim/neotest/neotest-pytest. Can't quite figure out which upgrade caused the regression

Yeah - I was suspecting this could be an issue in neotest proper as well, but just haven't spent enough time to figure out which.

@saharwenrix
Copy link

I had this bug on nightly build. when moving to v0.10.0 the bug was gone

@a3ng7n
Copy link
Author

a3ng7n commented Sep 24, 2024

I had this bug on nightly build. when moving to v0.10.0 the bug was gone

is that v0.10.0 of neotest? or neotest-python?

if you're able to do any testing that might help track whether this is a bug in neotest or neotest-python

@parisni
Copy link

parisni commented Nov 30, 2024

is that v0.10.0

sounds like he was talking about neovim version. BTW I'm also facing this issue on neovim 0.10.2

NOTE: After reinstalled properly it works, steps:

  1. :LazyExtra
  2. check lang-python and neotest
+  "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" },
+  "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" },

@Quitlox
Copy link

Quitlox commented Dec 18, 2024

For me, this issue had to do with an outdated version of plenary.nvim (symptoms exactly as described). The latest release of plenary is from 2023. Plenary is used to detect filetypes in neotest, which returned nil on this version. Installing the latest git version of plenary.nvim fixed the issue for me.

@olisikh
Copy link

olisikh commented Jan 2, 2025

Same issue on 0.10.2, all my Neotest adapters work fine, except Python for some reason.

But what is really funny, if I navigate into a Rust file with a test in it, and run the tests, then when I go back into the python file with tests and run them - neotest runs them 😅. If I make any test to fail, I can see python adapter actually reporting the test failure.

Otherwise I always see "No tests found" message.

@olisikh
Copy link

olisikh commented Jan 3, 2025

I think I found the root cause of this issue. If you just add one of the following files into the root folder, even an empty one:

"pyproject.toml", "setup.cfg", "mypy.ini", "pytest.ini", "setup.py"

which I had none of, then tests should be discovered and you should be able to run them. At least it started working for me.

The issue was in Adapter.get_root function, neotest was looking for any of these files and if none of them are found, then it considers the folder to be not a neotest-enabled workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants