Python Forum
capture pytest results to a file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: capture pytest results to a file (/thread-30331.html)



capture pytest results to a file - maiya - Oct-16-2020

Hi,

my_test.py::test_001_mytest PASSED                                               [ 50%]
my_test.py::test_002_mytest PASSED                                               [100%]

=========================================== 2 passed in 35.24s ===========================================
how to capture these pytest results to a file along with the stdout. Thanks for the suggestion.

Regards,
Maiya


RE: capture pytest results to a file - Askic - Oct-16-2020

(Oct-16-2020, 12:44 PM)maiya Wrote: Hi,

my_test.py::test_001_mytest PASSED                                               [ 50%]
my_test.py::test_002_mytest PASSED                                               [100%]

=========================================== 2 passed in 35.24s ===========================================
how to capture these pytest results to a file along with the stdout. Thanks for the suggestion.

Regards,
Maiya

I would type something like this in CMD (shell):
pytest >>results_test.txt

The results will be saved in the txt file


RE: capture pytest results to a file - maiya - Oct-17-2020

Quote:
(Oct-16-2020, 02:21 PM)Askic Wrote:
(Oct-16-2020, 12:44 PM)maiya Wrote: Hi,

my_test.py::test_001_mytest PASSED                                               [ 50%]
my_test.py::test_002_mytest PASSED                                               [100%]

=========================================== 2 passed in 35.24s ===========================================
how to capture these pytest results to a file along with the stdout. Thanks for the suggestion.

Regards,
Maiya

I would type something like this in CMD (shell):
pytest >>results_test.txt

The results will be saved in the txt file
Hi,
Thanks for your quick reply, however am looking for the pythonic way of doing it. since shell redirect or even using 'tee' command to redirect and display on stdout may not be looks good since it may not be colorized the output result of PASSED/FAILED.

If any suggestion or hint about the pythonic way of approach would be much appreciated. Thanks a lot.

Regards,
Maiya