Closed Willem-J-an closed 1 year ago
Thanks for figuring out the issue :smile: I've adjusted the argument parsing to correctly pass user args. Please try with the latest commit
Hi, Unfortunately it is not working yet for me.
Prepended the command now becomes this:
['neotest-python', '-p', '*_test.py', 'discover', '-s', '/home/user/code/module']
This is invalid because the pattern must come after discover. If the args are appended, it does work for me.
argv = ["neotest-python"] + self.id_to_unittest_args(args[-1]) + args[:-1]
Ah yep sorry about that, please try latest!
It works now for a directory with multiple tests, but not when running a single test. neotest-python: error: unrecognized arguments: -p *_test.py I guess the code path with multiple tests uses discover, which accepts this parameter, but the code path for a single test does not use discover, and does not accept this parameter.
OK it'll now pass the args in the correct order :sweat_smile:
It doesn't seem quite there yet for me unfortunately. From the summary panel I can:
What no longer works is:
From a testfile I can sucesfully expand and run all, I suppose this runs the entire file, which also works from the summary panel. I can not run a singular test with neotest.run.run().
The reason it does not work seems to be my discover arguments are passed to a non discover command when running a single testcase. usage: neotest-python [-h] [-v] [-q] [--locals] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [tests ...] neotest-python: error: unrecognized arguments: -p
neotest-python doesn't parse the args you pass, you have to be sure to pass the correct arguments. The args
option can be a function that receives two arguments: runner
("unittest" or "pytest") and position
which is a neotest.Position
so you can do something like this:
require("neotest-python")({
args = function (_, position)
if position.type == "test" or position.type == "namespace" then
return {}
end
return {"-p", "*_test.py"}
end
})
Ah great, that makes sense now! I would recommend to include this in the docs somewhere? Could be helpful for the next person! :smile:
Thanks a lot for the help
I raised this for neotest but I found the issue originates in this repo.
I provide my arguments to neotest-python like so:
These arguments are passed through all the way to the UnittestNeotestAdapter, which happily ignores them.
Processed by the adapter
This prevents my test file pattern from reaching the TestProgram, where an incorrect pattern is the default: test*.py
And so it was, that not a single test was tested :D Ran 0 tests in 0.000s