Skip to content

Commit 9263824

Browse files
PYT-BRAVO: Update readme (#2)
* doc: Update readme * docs: Update docs with new feature
1 parent 2a355c8 commit 9263824

1 file changed

Lines changed: 45 additions & 15 deletions

File tree

README.md

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,57 @@
11
# Pytrize
22

33
## Short summary
4+
45
Helps navigating `pytest.mark.parametrize` entries and fixtures by virtual text and jump to declaration commands, using `pytest`s cache and `treesitter`.
56

67
![pytrize](https://user-images.githubusercontent.com/23341710/143510539-c025925c-0e4c-4990-83ab-1c0da076c0f8.gif)
78

89
## What problems does this plugin solve?
10+
911
### Parametrize
12+
1013
`pytest` is amazing! The only thing that bothers me from time to time is if there are many entries in the parametrization of the test.
1114
If a test fails you might see for example:
15+
1216
```
1317
test.py::test[None2-a1-b-c1-8]
1418
```
19+
1520
Now you want to see what test case this actually corresponds to.
1621
What I sometimes do is to go to the entries in `pytest.mark.parametrize` and count the entries until I'm at the right one.
1722
But this is really not nice and easy to make a mistake, we should let the computer do this for us.
1823

1924
Enter `pytrize`.
2025

2126
### Fixture
27+
2228
Another issue is knowing where a certain fixture is defined and what it does.
2329

2430
## What does the plugin do?
25-
Three things:
26-
* Populates virtual text at the entries of `pytest.mark.parametrize` (see gif above), such that you can easily see which one is which.
31+
32+
Several things:
33+
34+
- Populates virtual text at the entries of `pytest.mark.parametrize` (see gif above), such that you can easily see which one is which.
2735
Done by calling `Pytrize` (and `PytrizeClear` to clear them).
2836
Alternatively `lua require('pytrize.api').set()` (and `lua require('pytrize.api').clear()`).
29-
* Provides a command to jump to the corresponding entry in `pytest.mark.parametrize` based on the test-case id under the cursor (see gif above).
37+
- Provides a command to jump to the corresponding entry in `pytest.mark.parametrize` based on the test-case id under the cursor (see gif above).
3038
Done by calling `PytrizeJump`.
3139
Alternatively `lua require('pytrize.api').jump()`.
3240
See the [Input](#input)-section below for cases where the file-path is not available.
33-
* Provides a command to jump to the declaration of the fixture under the cursor (by name), see [fixture](#jump-to-fixture) below.
41+
- Provides a command to jump to the declaration of the fixture under the cursor (by name), see [fixture](#jump-to-fixture) below.
3442
Done by calling `PytrizeJumpFixture`.
3543
Alternatively `lua require('pytrize.api').jump_fixture()`.
44+
- Provides a command to rename the fixture under the cursor (by name), see [fixture](#rename-fixture) below.
45+
Done by calling `PytrizeRenameFixture`.
46+
Alternatively `lua require('pytrize.api').rename_fixture()`.
3647

3748
## Installation
49+
3850
For example using [`packer`](https://github.com/wbthomason/packer.nvim):
51+
3952
```lua
4053
use { -- pytrize {{{
41-
'AckslD/nvim-pytrize.lua',
54+
'sigfriedcub1990/nvim-pytrize.lua',
4255
-- uncomment if you want to lazy load
4356
-- cmd = {'Pytrize', 'PytrizeClear', 'PytrizeJump'},
4457
-- uncomment if you want to lazy load but not use the commands
@@ -48,9 +61,12 @@ use { -- pytrize {{{
4861
```
4962

5063
For example using [`lazy.nvim`](https://github.com/folke/lazy.nvim):
64+
5165
```lua
52-
use { -- pytrize {{{
53-
'AckslD/nvim-pytrize.lua',
66+
{
67+
'sigfriedcub1990/nvim-pytrize.lua',
68+
version = '*',
69+
dependencies = { 'nvim-lua/plenary' },
5470
ft = 'python', -- Load only for python files
5571
opts = {},
5672
-- uncomment if you want to lazy load
@@ -61,40 +77,54 @@ use { -- pytrize {{{
6177
Requires [`plenary.nvim`](https://github.com/nvim-lua/plenary.nvim).
6278

6379
## Configuration
80+
6481
`require("pytrize").setup` takes an optional table of settings which currently have the default values:
82+
6583
```lua
6684
{
6785
no_commands = false,
6886
highlight = 'LineNr',
6987
preferred_input = 'telescope',
7088
}
7189
```
90+
7291
where:
73-
* `no_commands` can be set to `true` and the commands `Pytrize` etc won't be declared.
74-
* `highlight` defines the highlighting used for the virtual text.
75-
* `preferred_input` which method to query input to prefer (if it's installed), see the [Input](#input)-section below.
92+
93+
- `no_commands` can be set to `true` and the commands `Pytrize` etc won't be declared.
94+
- `highlight` defines the highlighting used for the virtual text.
95+
- `preferred_input` which method to query input to prefer (if it's installed), see the [Input](#input)-section below.
7696

7797
## Details
78-
* `pytest`s cache is used to find the test-case ids (eg `test.py::test[None2-a1-b-c1-8]`) which means that the tests have to be run at least once.
98+
99+
- `pytest`s cache is used to find the test-case ids (eg `test.py::test[None2-a1-b-c1-8]`) which means that the tests have to be run at least once.
79100
Also old ids might confuse `pytrize`, but you can clear the cache with `pytest --cache-clear`.
80-
* `treesitter` is used to find the correct entry in `pytest.mark.parametrize`.
101+
- `treesitter` is used to find the correct entry in `pytest.mark.parametrize`.
81102

82103
## Jump to fixture
104+
83105
To jump to the declaration of a fixture under the cursor, do `PytrizeJumpFixture`:
84106
![pytrize_fixture](https://user-images.githubusercontent.com/23341710/145707800-dcd49ae2-8fb1-46cc-8895-ed78ee5365b9.gif)
85107

108+
## Rename fixture
109+
110+
To rename the fixture under the cursor, do `PytrizeRenameFixture`:
111+
86112
## Input
113+
87114
In some cases the file-path is not printed by pytest, for example when a test fails when it might look something like:
115+
88116
```
89117
90118
_________________________________ test[None2-a1-b-c1-9] _________________________________
91119
```
120+
92121
or similar.
93122
If you trigger to jump to the declaration of the parameters in this case `pytrize` will find all files in the cache that matches this test-case id and if there is more than one ask you which one to jump to.
94123
Currently three input methods are supported:
95-
* [`telescope`](https://github.com/nvim-telescope/telescope.nvim)
124+
125+
- [`telescope`](https://github.com/nvim-telescope/telescope.nvim)
96126
![pytrize_input_telescope](https://user-images.githubusercontent.com/23341710/145381466-42152977-f412-425d-9ddb-cc0c4dfde4fb.gif)
97-
* [`nui`](https://github.com/MunifTanjim/nui.nvim)
127+
- [`nui`](https://github.com/MunifTanjim/nui.nvim)
98128
![pytrize_input_nui](https://user-images.githubusercontent.com/23341710/145381492-5e5abec0-c8c5-468c-90ee-b854e9d57146.gif)
99-
* `inputlist` (neovim native)
129+
- `inputlist` (neovim native)
100130
![pytrize_input_builtin](https://user-images.githubusercontent.com/23341710/145381515-4afb6d1b-e6f5-4c55-bfc8-99d086f0f3b2.gif)

0 commit comments

Comments
 (0)