Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
pytest Quick Start Guide

You're reading from   pytest Quick Start Guide Write better Python code with simple and maintainable tests

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789347562
Length 160 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Bruno Oliveira Bruno Oliveira
Author Profile Icon Bruno Oliveira
Bruno Oliveira
Arrow right icon
View More author details
Toc

Fixtures

In the previous chapter, we learned how to use marks and parametrization effectively to skip tests, mark them as expected to fail, and parameterize them, to avoid repetition.

Tests in the real world often need to create resources or data to work on: a temporary directory to output some files to, a database connection to test the I/O layer of an application, a web server for integration testing. Those are all examples of resources that are required in more complex testing scenarios. More complex resources often need to be cleaned up at the end of the test session: removing a temporary directory, cleaning up and disconnecting from a database, shutting down a web server. Also, these resources should be easily shared across tests, because during testing we often need to reuse a resource for different test scenarios. Some resources are costly to create, but because they are...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime