Skip to content

Commit 3d46492

Browse files
committed
docs(developing): Update with examples of PYTEST_ADDOPTS
1 parent 7b607c7 commit 3d46492

File tree

1 file changed

+92
-23
lines changed

1 file changed

+92
-23
lines changed

docs/developing.md

+92-23
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,88 @@ That is it! You are now ready to code!
117117

118118
## Test Runner
119119

120+
[pytest] is used for tests.
121+
120122
As you seen above, the `tmuxp` command will now be available to you,
121123
since you are in the virtual environment, your {}`PATH` environment was
122124
updated to include a special version of `python` inside your `.venv`
123125
folder with its own packages.
124126

127+
### Rerun on file change
128+
129+
via [pytest-watcher] (works out of the box):
130+
131+
```console
132+
$ make start
133+
```
134+
135+
via [entr(1)] (requires installation):
136+
137+
```console
138+
$ make watch_test
139+
```
140+
141+
[pytest-watcher]: https://github.com/olzhasar/pytest-watcher
142+
143+
### Manual (just the command, please)
144+
125145
```console
146+
$ poetry run py.test
147+
```
126148

149+
or:
150+
151+
```console
127152
$ make test
153+
```
154+
155+
### pytest options
128156

157+
`PYTEST_ADDOPTS` can be set in the commands below. For more
158+
information read [docs.pytest.com] for the latest documentation.
159+
160+
[docs.pytest.com]: https://docs.pytest.org/
161+
162+
Verbose:
163+
164+
```console
165+
$ env PYTEST_ADDOPTS="-verbose" make start
166+
```
167+
168+
Pick a file:
169+
170+
```console
171+
$ env PYTEST_ADDOPTS="tests/test_workspacebuilder.py" poetry run make start
172+
```
173+
174+
Drop into `test_automatic_rename_option()` in `tests/test_workspacebuilder.py`:
175+
176+
```console
177+
$ env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py" poetry run make start
178+
```
179+
180+
Drop into `test_automatic_rename_option()` in `tests/test_workspacebuilder.py` and stop on first error:
181+
182+
```console
183+
$ env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py::test_automatic_rename_option" poetry run make start
184+
```
185+
186+
Drop into `pdb` on first error:
187+
188+
```console
189+
$ env PYTEST_ADDOPTS="-x -s --pdb" make start
190+
```
191+
192+
If you have [ipython] installed:
193+
194+
```console
195+
$ env PYTEST_ADDOPTS="--pdbcls=IPython.terminal.debugger:TerminalPdb" make start
196+
```
197+
198+
[ipython]: https://ipython.org/
199+
200+
```console
201+
$ make test
129202
```
130203

131204
You probably didn't see anything but tests scroll by.
@@ -140,27 +213,21 @@ If you found a problem or are trying to write a test, you can file an
140213
Test only a file:
141214

142215
```console
143-
144216
$ py.test tests/test_config.py
145-
146217
```
147218

148219
will test the `tests/test_config.py` tests.
149220

150221
```console
151-
152222
$ py.test tests/test_config.py::test_export_json
153-
154223
```
155224

156225
tests `test_export_json` inside of `tests/test_config.py`.
157226

158227
Multiple can be separated by spaces:
159228

160229
```console
161-
162230
$ py.test tests/test_{window,pane}.py tests/test_config.py::test_export_json
163-
164231
```
165232

166233
(test-builder-visually)=
@@ -172,15 +239,15 @@ open in a separate terminal.
172239

173240
Create two terminals:
174241

175-
> > - Terminal 1: `$ tmux -L test_case`
176-
>
177-
> - Terminal 2: `$ cd` into the tmuxp project and into the
178-
> `virtualenv` if you are using one, see details on installing the dev
179-
> version of tmuxp above. Then:
180-
>
181-
> ```
182-
> $ py.test tests/test_workspacebuilder.py
183-
> ```
242+
- Terminal 1: `$ tmux -L test_case`
243+
244+
- Terminal 2: `$ cd` into the tmuxp project and into the
245+
`virtualenv` if you are using one, see details on installing the dev
246+
version of tmuxp above. Then:
247+
248+
```console
249+
$ py.test tests/test_workspacebuilder.py
250+
```
184251

185252
Terminal 1 should have flickered and built the session before your eyes.
186253
tmuxp hides this building from normal users.
@@ -195,40 +262,42 @@ This requires `entr(1)`.
195262

196263
:::
197264

198-
Install [entr][entr]. Packages are available available on most Linux and BSD
265+
Install [entr]. Packages are available available on most Linux and BSD
199266
variants, including Debian, Ubuntu, FreeBSD, OS X.
200267

201268
To run all tests upon editing any `.py` file:
202269

203270
```console
204-
205271
$ make watch_test
206-
207272
```
208273

209274
You can also re-run a specific test file or any other [py.test usage
210275
argument][py.test usage argument]:
211276

212277
```console
213-
214278
$ make watch_test test=tests/test_config.py
279+
```
215280

281+
```console
216282
$ make watch_test test='-x tests/test_config.py tests/test_util.py'
217-
218283
```
219284

220285
## Rebuild sphinx docs on save
221286

222287
Rebuild the documentation when an `.rst` file is edited:
223288

224289
```console
225-
226290
$ cd doc
291+
```
292+
293+
```console
227294
$ make watch
295+
```
228296

229-
# If you're not source'd via `poetry shell`, you can use this:
230-
$ make SPHINXBUILD='poetry run sphinx-build' watch
297+
If you're not source'd via `poetry shell`, you can use this:
231298

299+
```console
300+
$ make SPHINXBUILD='poetry run sphinx-build' watch
232301
```
233302

234303
(tmuxp-developer-config)=

0 commit comments

Comments
 (0)