Skip to content

allow capture to output while also storing the data internally (like tee) #2325

@sangmeshcp

Description

@sangmeshcp

when i run the test case i have lot of logs which use logger and print in my testcase.. i need mechanism where i can print all the logs while its being executed on screen and capture it to a file descriptor simultaneously .

pytest -s test.py (pytest --capture=no test.py )

when I run the logs are printed to sys.stdout which is right ..

what I'm looking for is

pytest --capture=no,fd

this will ensure i can see what is happening while the test is being executed and the logs are written to the fd which is a file.

example :

$ pytest --capture=no test.py 
============================================================= test session starts =============================================================
platform linux -- Python 3.4.3, pytest-3.0.7, py-1.4.32, pluggy-0.4.0
rootdir: /tmp, inifile:
collected 8 items 

printing testing 123 123 123 from test.. 
None
.



------------------------------------------------------------- Test Summary Begin --------------------------------------------------------------
test.py::test::()::                    : Passed   

-------------------------------------------------------------- Test Summary End ---------------------------------------------------------------

the output "printing testing 123 123 123 from test.. " need to written to file as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementnew feature or API change, should be merged into features branchtype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions