Comments (13)
is_test_file = function(file_path) end
This is going to always say a file path is not a test file because of implicitly returning nil
. Remove it from the config
from neotest.
I tried using this instead:
require("neotest").setup({
adapters = {
require("neotest-python")({
-- Extra arguments for nvim-dap configuration
dap = { justMyCode = false },
-- Command line arguments for runner
-- Can also be a function to return dynamic values
args = {"--log-level", "DEBUG"},
-- Runner to use. Will use pytest if available by default.
-- Can be a function to return dynamic value.
runner = "unittest"
})
}
})
But I get the same result.
from neotest.
my_test_case
is not a valid test name, please be sure the tests are actually runnable using the unittest cli.
from neotest.
That was just a mve. I changed it to test_my_test_case
and it's the same issue.
arman@docker-desktop: ~ $ python -m unittest mytest.py
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
from neotest.
OK can you update your plugins to the latest, retry and provide the log in vim.fn.stdpath("log") .. "neotest.log"
?
from neotest.
INFO | 2022-07-02T23:33:12Z+1000 | ....config/nvim/plugged/neotest/lua/neotest/client/init.lua:522 | Initialising client
INFO | 2022-07-02T23:33:12Z+1000 | ....config/nvim/plugged/neotest/lua/neotest/client/init.lua:589 | Initialisation finished in 0 seconds
from neotest.
Just saw your test file name is mytest.py
, this is not an expected test file name. If you run python -m unittest
it won't see your file. You should rename it to test_mytest.py
. You can force it to be detected by neotest by changing the is_test_file
option but it won't work when running directories
from neotest.
Changed the name to test_mytest.py
. No change.
arman@docker-desktop: ~/stuff $ python -m unittest
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
from neotest.
If you use this init.lua
does it work? nvim --clean -u min.lua test_mytest.py
-- ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))
vim.opt.termguicolors = true
-- append test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))
-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
vim.cmd("packadd packer.nvim")
install_plugins = true
end
local packer = require("packer")
packer.init({
package_root = test_dir .. "/pack",
compile_path = test_dir .. "/plugin/packer_compiled.lua",
})
packer.startup(function(use)
-- Packer can manage itself
use("wbthomason/packer.nvim")
use("vim-test/vim-test")
use({
"nvim-neotest/neotest",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-python",
},
config = function()
require("neotest").setup({
adapters = {
require("neotest-python")({
dap = { justMyCode = false },
args = { "--log-level", "DEBUG" },
runner = "unittest",
}),
},
})
end,
})
if install_plugins then
packer.sync()
end
end)
vim.cmd([[
command! NeotestSummary lua require("neotest").summary.toggle()
command! NeotestFile lua require("neotest").run.run(vim.fn.expand("%"))
command! Neotest lua require("neotest").run.run(vim.fn.getcwd())
command! NeotestNearest lua require("neotest").run.run()
command! NeotestDebug lua require("neotest").run.run({ strategy = "dap" })
command! NeotestAttach lua require("neotest").run.attach()
]])
from neotest.
You'll also have to run TSInstall python
and restart after installing plugins
from neotest.
It seems to work with that init.lua file you provided:
import unittest
class MyTest(unittest.TestCase):
✔ def test_my_test_case(self) -> None:
self.assertTrue(True)
I'm confused about what the difference is though, as I thought that the init.vim file I provided in the OP is basically the same thing as what you gave me, but somehow it seems to work. Any ideas?
from neotest.
Ah so I tried again with my init.vim and it actually worked fine after running TSInstall python
, so apparently that was the missing step.
from neotest.
diff --git a/README.md b/README.md
index ba87818..39fd4a6 100644
--- a/README.md
+++ b/README.md
@@ -27,12 +27,12 @@ See `:h neotest` for details on neotest is designed and how to interact with it
## Installation
-Neotest uses [plenary.nvim](https://github.com/nvim-lua/plenary.nvim/).
-
-Most adapters will also require [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
-
Neotest uses the `CursorHold` event which has issues in NeoVim: [see here](https://github.com/neovim/neovim/issues/12587) \
-It's recommended to use https://github.com/antoinemadec/FixCursorHold.nvim.
+It's recommended to use https://github.com/antoinemadec/FixCursorHold.nvim. Neotest uses \
+[plenary.nvim](https://github.com/nvim-lua/plenary.nvim/). Most adapters will also require \
+[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) (and for the correct \
+[language parser](https://github.com/nvim-treesitter/nvim-treesitter#language-parsers) to be installed, e.g. by running\
+`:TSInstall all`).
Install with your favourite package manager alongside nvim-dap
from neotest.
Related Issues (20)
- Feature Request: Set Notification Levels
- [BUG] Getting error "Future already set" and output_panel is empty for python tests HOT 7
- [Feature Request] Boost.Test supporting HOT 2
- Deprecation warnings on neovim 0.11
- [BUG] Summary opens, but no help HOT 2
- Graciously handling DAP failure on multistep (build then run) languages HOT 1
- [doc] Replace README recommendation of neodev with lazydev
- New Adapter: neotest-ctest - A neotest adapter for C/C++ using CTest as a test runner HOT 1
- [BUG] ImportError while importing test module HOT 3
- [BUG] "No tests found" when opening the summary window rigth before running tests the first time HOT 1
- [BUG] Java file watcher does not work as the jdtls is marked as an invalid lsp HOT 1
- Lazy load adapters HOT 1
- [Question] Subprocess with `--clean` flag
- [Feature Request] Enable setting custom environment variables for summary runs HOT 2
- [Feature] option to hide the adapter name
- [Documentation] RunSpec stream clarification HOT 2
- [BUG] scm-1 rockspec still has nvim-treesitter in its dependencies HOT 1
- [BUG] CMD Neotest Summary freezes Neovim HOT 1
- [BUG] Async call does not work inside is_test_file function
- [BUG] Slow starup time HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neotest.