[pytest-dev] Preserving capture fd from fixture setup?

Nikolaus Rath Nikolaus at rath.org
Tue May 31 13:17:21 EDT 2016


On May 28 2016, holger krekel <holger-TO2CgvPYN1Lsq35pWSNszA at public.gmane.org> wrote:
> Hi Nikolaus,
>
> On Thu, May 19, 2016 at 12:34 -0700, Nikolaus Rath wrote:
>> Hello,
>> 
>> I am testing a server. I am starting the server in a subprocess from a
>> fixture, and then issue requests to it from various tests. Unfortunately
>> this seems to have one big drawback: when a test fails, the capture
>> plugin does not display any output from the server process.
>>
>> After looking at the code, I think this is because the capture plugin
>> creates a new file descriptor for each test phase (setup, call,
>> teardown).
>
> it reuses the same file descriptor for capturing IIRC.  After each
> phase (setup, call, teardown) the FD is reset to position 0.

Hmm. Yeah, on closer inspection my test case was flawed - adding a
.flush() at the end of the setup code made the output appear in the
right spot. But my original problem remains.


> Is your problem that the server is started during fixture setup
> and you'd like to see its standard out/err during the test call phase?

Exactly.


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«


More information about the pytest-dev mailing list