Crafting Test-Driven Software with Python by Alessandro Molina

Crafting Test-Driven Software with Python by Alessandro Molina

Author:Alessandro Molina [Alessandro Molina]
Language: eng
Format: epub
Tags: COM051360 - COMPUTERS / Programming Languages / Python, COM051440 - COMPUTERS / Software Development and Engineering / Tools, COM053000 - COMPUTERS / Security / General
Publisher: Packt Publishing
Published: 2021-02-18T06:34:22+00:00


out, err = capsys.readouterr()

assert out == "MyApp Started
"

The test_capsys test just starts the application (running myapp), then through capsys.readouterr() it retrieves the content of sys.stdout and sys.stderr snapshotted at that moment.

Once the standard output content is available, it can be compared to the expected one to confirm that the application actually printed what we wanted. If the application really printed "MyApp Started" as expected, running the test should pass and confirm that's the content of the standard output:

$ pytest test_capsys.py -v

===== test session starts =====

...

collected 1 item



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.