pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Add hook to suspend/resume capturing

Open blueyed opened this issue 7 years ago • 5 comments

Currently there are several places where this gets done manually:

https://github.com/pytest-dev/pytest/blob/85288b53218d4e0037dce9c34bd37f86fa9e212d/src/_pytest/debugging.py#L253-L260

https://github.com/pytest-dev/pytest/blob/85288b53218d4e0037dce9c34bd37f86fa9e212d/src/_pytest/doctest.py#L206-L217

https://github.com/pytest-dev/pytest/blob/85288b53218d4e0037dce9c34bd37f86fa9e212d/src/_pytest/setuponly.py#L47-L51 (this one is not display out/err)

https://github.com/pytest-dev/pytest/blob/85288b53218d4e0037dce9c34bd37f86fa9e212d/src/_pytest/debugging.py#L180-L192

I think it might be good to use a hook / hooks for this instead.

The idea comes via the debugging plugin, where capman would suspend/resume on the enter_pdb and leave_pdb hooks from there - but it seems like it makes more sense to have this more generic then.

blueyed avatar Nov 09 '19 20:11 blueyed

i believe we are looking for "api" here not "hook" - ideally we provide something in the capture plug-in that takes config and does the rest,

do you have something in mind/pseudo code?

RonnyPfannschmidt avatar Nov 10 '19 14:11 RonnyPfannschmidt

No, I've meant hook - the capman/capture plugin would be the reference implementation then, but e.g. some other plugin could also react/handle it, e.g. the debugging plugin.

blueyed avatar Nov 10 '19 16:11 blueyed

then i don't follow wrt the intended structure, do you have an minimal example that outlines the control flow that's intended?

RonnyPfannschmidt avatar Nov 10 '19 18:11 RonnyPfannschmidt

Hey I was gonna do this manually but since it was marked as completed, could you direct me towards any changes that were made to address this?

saumzzz avatar Sep 06 '23 08:09 saumzzz

it was closed without addressing, lets create a new issue with a workable solution

RonnyPfannschmidt avatar Sep 06 '23 08:09 RonnyPfannschmidt