neotest-python 项目使用教程
neotest-python项目地址:https://gitcode.com/gh_mirrors/ne/neotest-python
1. 项目的目录结构及介绍
neotest-python 项目的目录结构如下:
neotest-python/
├── lua/
│ └── neotest-python/
│ └── neotest_python.lua
├── scripts/
├── .gitignore
├── LICENSE.md
├── README.md
├── neotest.py
├── pyproject.toml
├── stylua.toml
目录结构介绍
lua/neotest-python/
: 包含 neotest-python 的核心 Lua 脚本文件。scripts/
: 包含项目的辅助脚本。.gitignore
: 指定 Git 版本控制系统忽略的文件和目录。LICENSE.md
: 项目的许可证文件。README.md
: 项目的说明文档。neotest.py
: 项目的 Python 脚本文件。pyproject.toml
: 项目的配置文件,用于定义项目依赖和构建工具。stylua.toml
: 用于配置 Lua 代码格式化的工具。
2. 项目的启动文件介绍
项目的启动文件是 lua/neotest-python/neotest_python.lua
。这个文件是 neotest-python 插件的核心,负责配置和启动 neotest 适配器。
启动文件内容概述
-
初始化 neotest 适配器:
require("neotest").setup({ adapters = { require("neotest-python") } })
-
可选配置项:
require("neotest").setup({ adapters = { require("neotest-python")({ -- Extra arguments for nvim-dap configuration dap = { justMyCode = false }, -- Command line arguments for runner args = ["--log-level", "DEBUG"], -- Runner to use runner = "pytest", -- Custom python path for the runner python = "venv/bin/python" }) } })
3. 项目的配置文件介绍
项目的配置文件主要包括 pyproject.toml
和 stylua.toml
。
pyproject.toml
pyproject.toml
文件用于定义项目的依赖和构建工具。以下是一个示例:
[tool.poetry]
name = "neotest-python"
version = "0.1.0"
description = "Neotest adapter for python"
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.8"
pytest = "^6.2"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
stylua.toml
stylua.toml
文件用于配置 Lua 代码格式化的工具。以下是一个示例:
column_width = 80
indent_width = 2
quote_style = "single"
通过这些配置文件,可以确保项目的依赖管理、构建过程和代码格式化的一致性。
neotest-python项目地址:https://gitcode.com/gh_mirrors/ne/neotest-python