You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running on the tests folder should still run as expected (or, if there was a subfolder, it should also run as expected). This is working for pytest but not for unittest.
The likely reason for the failure is because the test runner isn't sourcing tests/__init__.py when Neotest runs on a directory but tests/__init__.py is sourced when you run on a file. When I need to run unittests based on a directory, I typically do python -m unittest discover --start-directory tests/ or python -m unittest discover --start-directory tests/some_subfolder/ to make sure all __init__.py files are sourced correctly. Could neotest-python be adjusted to make sure tests run consistently regardless of the test's starting point?
The text was updated successfully, but these errors were encountered:
Which isn't enough context for the unittest. According to unittest discover's help
-t TOP, --top-level-directory TOP
Top level directory of project (defaults to start
directory)
When -s is given but -t is not, unittest discover assumes that the given directory is the top of the project so it doesn't search __init__.py from that point.
Demo
neotest_unittest_runner_directory_fail.mp4
Description
Reproduction Details
:Neotest summary
r
on thetests
folderunittest
runner enabled inreproduction_neotest_test.lua
, it failspytest
runner enabled inreproduction_neotest_test.lua
, it succeedsReproduction Files
(You don't need this file, it's in the tar.gz. But pasted it here so people can see
reproduction.lua
Expected
Running on the tests folder should still run as expected (or, if there was a subfolder, it should also run as expected). This is working for pytest but not for unittest.
The likely reason for the failure is because the test runner isn't sourcing
tests/__init__.py
when Neotest runs on a directory buttests/__init__.py
is sourced when you run on a file. When I need to run unittests based on a directory, I typically dopython -m unittest discover --start-directory tests/
orpython -m unittest discover --start-directory tests/some_subfolder/
to make sure all__init__.py
files are sourced correctly. Could neotest-python be adjusted to make sure tests run consistently regardless of the test's starting point?The text was updated successfully, but these errors were encountered: