@@ -117,15 +117,88 @@ That is it! You are now ready to code!
117
117
118
118
## Test Runner
119
119
120
+ [ pytest] is used for tests.
121
+
120
122
As you seen above, the ` tmuxp ` command will now be available to you,
121
123
since you are in the virtual environment, your {}` PATH ` environment was
122
124
updated to include a special version of ` python ` inside your ` .venv `
123
125
folder with its own packages.
124
126
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
+
125
145
``` console
146
+ $ poetry run py.test
147
+ ```
126
148
149
+ or:
150
+
151
+ ``` console
127
152
$ make test
153
+ ```
154
+
155
+ ### pytest options
128
156
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
129
202
```
130
203
131
204
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
140
213
Test only a file:
141
214
142
215
``` console
143
-
144
216
$ py.test tests/test_config.py
145
-
146
217
```
147
218
148
219
will test the ` tests/test_config.py ` tests.
149
220
150
221
``` console
151
-
152
222
$ py.test tests/test_config.py::test_export_json
153
-
154
223
```
155
224
156
225
tests ` test_export_json ` inside of ` tests/test_config.py ` .
157
226
158
227
Multiple can be separated by spaces:
159
228
160
229
``` console
161
-
162
230
$ py.test tests/test_{window,pane}.py tests/test_config.py::test_export_json
163
-
164
231
```
165
232
166
233
(test-builder-visually)=
@@ -172,15 +239,15 @@ open in a separate terminal.
172
239
173
240
Create two terminals:
174
241
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
+ ```
184
251
185
252
Terminal 1 should have flickered and built the session before your eyes.
186
253
tmuxp hides this building from normal users.
@@ -195,40 +262,42 @@ This requires `entr(1)`.
195
262
196
263
:::
197
264
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
199
266
variants, including Debian, Ubuntu, FreeBSD, OS X.
200
267
201
268
To run all tests upon editing any ` .py ` file:
202
269
203
270
``` console
204
-
205
271
$ make watch_test
206
-
207
272
```
208
273
209
274
You can also re-run a specific test file or any other [ py.test usage
210
275
argument] [ py.test usage argument ] :
211
276
212
277
``` console
213
-
214
278
$ make watch_test test=tests/test_config.py
279
+ ```
215
280
281
+ ``` console
216
282
$ make watch_test test=' -x tests/test_config.py tests/test_util.py'
217
-
218
283
```
219
284
220
285
## Rebuild sphinx docs on save
221
286
222
287
Rebuild the documentation when an ` .rst ` file is edited:
223
288
224
289
``` console
225
-
226
290
$ cd doc
291
+ ```
292
+
293
+ ``` console
227
294
$ make watch
295
+ ```
228
296
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:
231
298
299
+ ``` console
300
+ $ make SPHINXBUILD=' poetry run sphinx-build' watch
232
301
```
233
302
234
303
(tmuxp-developer-config)=
0 commit comments