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
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.
Exploring Deepfakes by Bryan Lyon and Matt Tora(7476)
Robo-Advisor with Python by Aki Ranin(7356)
Offensive Shellcode from Scratch by Rishalin Pillay(5969)
Ego Is the Enemy by Ryan Holiday(4900)
Microsoft 365 and SharePoint Online Cookbook by Gaurav Mahajan Sudeep Ghatak Nate Chamberlain Scott Brewster(4746)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4421)
Python for ArcGIS Pro by Silas Toms Bill Parker(4047)
Elevating React Web Development with Gatsby by Samuel Larsen-Disney(3751)
Machine Learning at Scale with H2O by Gregory Keys | David Whiting(3466)
Learning C# by Developing Games with Unity 2021 by Harrison Ferrone(3265)
Speed Up Your Python with Rust by Maxwell Flitton(3221)
Liar's Poker by Michael Lewis(3197)
OPNsense Beginner to Professional by Julio Cesar Bueno de Camargo(3182)
Extreme DAX by Michiel Rozema & Henk Vlootman(3158)
Agile Security Operations by Hinne Hettema(3110)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic and Jasmin Redzepagic(3101)
Essential Cryptography for JavaScript Developers by Alessandro Segala(3073)
Cryptography Algorithms by Massimo Bertaccini(2989)
AI-Powered Commerce by Andy Pandharikar & Frederik Bussler(2970)
