Pattern – running a subset of tests
We already saw a simple way of running a subset of tests by simply specifying the module or test class on the command line, as shown in the following:
python -m unittest stock_alerter.tests.test_stock python -m unittest stock_alerter.tests.test_stock.StockTest
This works for the common case of when we want to run a subset based on the module. What if we want to run tests based on some other parameter? Maybe we want to run a set of basic smoke tests, or we want to run only integration tests, or we want to skip tests when running on a specific platform or Python version.
The unittest
module allows us to create test suites. A test suite is a collection of test classes that are run. By default, unittest
performs an ...
Get Test-Driven Python Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.