Search icon CANCEL
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
Crafting Test-Driven Software with Python

You're reading from   Crafting Test-Driven Software with Python Write test suites that scale with your applications' needs and complexity using Python and PyTest

Arrow left icon
Product type Paperback
Published in Feb 2021
Publisher Packt
ISBN-13 9781838642655
Length 338 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alessandro Molina Alessandro Molina
Author Profile Icon Alessandro Molina
Alessandro Molina
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Section 1: Software Testing and Test-Driven Development
2. Getting Started with Software Testing FREE CHAPTER 3. Test Doubles with a Chat Application 4. Test-Driven Development while Creating a TODO List 5. Scaling the Test Suite 6. Section 2: PyTest for Python Testing
7. Introduction to PyTest 8. Dynamic and Parametric Tests and Fixtures 9. Fitness Function with a Contact Book Application 10. PyTest Essential Plugins 11. Managing Test Environments with Tox 12. Testing Documentation and Property-Based Testing 13. Section 3: Testing for the Web
14. Testing for the Web: WSGI versus HTTP 15. End-to-End Testing with the Robot Framework 16. About Packt 17. Other Books You May Enjoy

Testing multiple Python versions with Tox

Tox is based on the concept of environments. The goal of Tox is to prepare those environments where it will run the commands provided. Usually, those environments are meant for testing (running tests in different conditions) and the most common kind of environments are those that use different Python versions. But in theory, it is possible to create a different environment for any other purpose. For example, we frequently create an environment where project documentation is built.

To add further environments to Tox, it's sufficient to list them inside the envlist = option. To configure two environments that test our project against both Python 2.7 and Python 3.7, we can set envlist to both py37 and py27:

[tox]
setupdir = ./src
envlist = py27, py37

If we run tox again, we will see that it will now test our project on two different environments, one made for Python 2.7 and one for Python 3.7:

$ tox
GLOB sdist-make: ./src/setup.py

py27 create: ...
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 €18.99/month. Cancel anytime