You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
with capsys.disabled() causes "I/O operation on closed file" #1873
I suspect the error is happening because some code is opening and keeping a reference to a log file somewhere, and capsys.disabled() closes that file to restore the original stdin. If that's the case and the above suggestion does not work, I'm afraid there's nothing that can be done on our side.
It is probably setting up a logger at module level, which is actually the usual approach to logging.
I think we can close this as there is nothing that can be done on Pytest's side. Feel free to reopen if you still want to discuss something or have other questions. 😁
Activity
nicoddemus commentedon Aug 26, 2016
Thanks for the report.
Did this worked in a previous version? Could please you post a reproducible example?
The-Compiler commentedon Aug 26, 2016
capsys.disabled()was added in 3.0 (by that guy with a penguin avatar) 😉nicoddemus commentedon Aug 26, 2016
Duh 😅
@brechtm I see you are constructing the
sphinxobject outside thewithstatement:Try construct the
sphinxobject inside thewithstatement to see if it helps:I suspect the error is happening because some code is opening and keeping a reference to a log file somewhere, and
capsys.disabled()closes that file to restore the originalstdin. If that's the case and the above suggestion does not work, I'm afraid there's nothing that can be done on our side.brechtm commentedon Aug 26, 2016
Nope, the problem persists if I make the instantiation part of the context. It does work, however, if I also move the import statement to the content:
Which might indicate some nasty trickery going on in the Sphinx modules, indeed :-)
nicoddemus commentedon Aug 26, 2016
It is probably setting up a logger at module level, which is actually the usual approach to logging.
I think we can close this as there is nothing that can be done on Pytest's side. Feel free to reopen if you still want to discuss something or have other questions. 😁