mfussenegger / nvim-dap-python

An extension for nvim-dap, providing default configurations for python and methods to debug individual test methods or classes.
GNU General Public License v3.0
492 stars 46 forks source link

Expanding Pytest configuration lookup #142

Closed julianolf closed 1 month ago

julianolf commented 1 month ago

First of all, I just wanted to say thanks for the awesome plugin! It just makes configuring a debugger for Python on nvim as easy as it can be.

Going on the topic, I recently started working on a project that moved all tooling configurations to the pyproject.toml file, including Pytest's. Because of this, debugging tests required manually setting up the test runner.

I tried to create an empty pytest.ini file as a workaround, but then Pytest stopped reading the pyproject.toml file. According to the documentation, pytest.ini and .pytest.ini files take precedence over other configuration files. https://docs.pytest.org/en/8.2.x/reference/customize.html#configuration-file-formats

I like the way I used to move between projects with different test runners without having to do anything special or complicated—just open files, hit a few keys, and start debugging.

To regain that convenience, I wrote a function that searches for Pytest configurations in various files (pytest.ini, .pytest.ini, pyproject.toml, tox.ini, and setup.cfg), as described in the documentation.

I was wondering if adding this complexity to look for Pytest configurations in different files is something you would be willing to incorporate into the plugin?

mfussenegger commented 1 month ago

I was wondering if adding this complexity to look for Pytest configurations in different files is something you would be willing to incorporate into the plugin?

I don't want to go too overboard with the detection, but I added pyproject.toml with https://github.com/mfussenegger/nvim-dap-python/pull/144 seeing how pyproject.toml has full core backing with PEPs and all.

julianolf commented 1 month ago

It works perfect for me. Thanks for the addition!