Unit testing with pytest
We can create unit tests using a library that provides a common framework for the test scenarios, along with a test runner to execute the tests and log results. Unit tests focus on testing the least amount of code possible in any one test. The standard library includes the
unittest package. While widely used, this package tends to force us to create a fair amount of boilerplate code for each test case.
One of the more popular alternatives to the standard library
pytest. This has the advantage of letting us write smaller, and more clear, test cases. The lack of overheads makes this a desirable alternative.
pytest is not part of the standard library, you'll need to download and install it yourself. You can get it from the
pytest home page at https://docs.pytest.org/en/stable/. You can install it with any of the installers.
In a Terminal window, activate the virtual environment you're working in...