@@ -254,17 +254,18 @@ regarding to use custom hooks.
254
254
``pytest_timeout_set_timer ``
255
255
----------------------------
256
256
257
- @pytest.hookspec(firstresult=True)
258
- def pytest_timeout_set_timer(item, settings):
259
- """Called at timeout setup.
257
+ .. code :: python
260
258
261
- 'item' is a pytest node to setup timeout for.
259
+ @pytest.hookspec (firstresult = True )
260
+ def pytest_timeout_set_timer (item , settings ):
261
+ """ Called at timeout setup.
262
262
263
- 'settings ' is Settings namedtuple (described below) .
263
+ 'item ' is a pytest node to setup timeout for .
264
264
265
- Can be overridden by plugins for alternative timeout implementation strategies .
265
+ 'settings' is Settings namedtuple (described below) .
266
266
267
- """
267
+ Can be overridden by plugins for alternative timeout implementation strategies.
268
+ """
268
269
269
270
270
271
``Settings ``
@@ -289,31 +290,33 @@ The argument has ``Settings`` namedtuple type with the following fields:
289
290
``pytest_timeout_cancel_timer ``
290
291
-------------------------------
291
292
293
+ .. code :: python
292
294
293
- @pytest.hookspec(firstresult=True)
294
- def pytest_timeout_cancel_timer(item):
295
- """Called at timeout teardown.
296
-
297
- 'item' is a pytest node which was used for timeout setup.
295
+ @pytest.hookspec (firstresult = True )
296
+ def pytest_timeout_cancel_timer (item ):
297
+ """ Called at timeout teardown.
298
298
299
- Can be overridden by plugins for alternative timeout implementation strategies .
299
+ 'item' is a pytest node which was used for timeout setup .
300
300
301
- """
301
+ Can be overridden by plugins for alternative timeout implementation strategies.
302
+ """
302
303
303
304
``is_debugging ``
304
305
----------------
305
306
306
307
When the timeout occurs, user can open the debugger session. In this case, the timeout
307
308
should be discarded. A custom hook can check this case by calling ``is_debugging() ``
308
- function::
309
+ function:
310
+
311
+ .. code :: python
309
312
310
- import pytest
311
- import pytest_timeout
313
+ import pytest
314
+ import pytest_timeout
312
315
313
- def on_timeout():
314
- if pytest_timeout.is_debugging():
315
- return
316
- pytest.fail("+++ Timeout +++")
316
+ def on_timeout ():
317
+ if pytest_timeout.is_debugging():
318
+ return
319
+ pytest.fail(" +++ Timeout +++" )
317
320
318
321
319
322
Changelog
0 commit comments