From the course: Unit Testing in Python
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Parametrization - Python Tutorial
From the course: Unit Testing in Python
Parametrization
- [Instructor] When making tests, you may realize that there are a few different cases you want your test to cover. For instance, let's say you have a function that returns statistics, either a mean or a median for a specified country within our processed CSV data. On line 28 of the test_parametrized_start.py file, you can see the test function verifying that a returned dictionary object contains the appropriate average altitude for Andorra. On line 35, a separate test checks if the function returns a dictionary with the appropriate median altitude for the country as well. We can use Pytest parameterization decorator to combine both of these happy path tests into one and also include other testing scenarios we'd like to check. When looking at the Pytest documentation, you'll see information about the parametrized decorator. Here you'll notice that they spell parametrize according to the British spelling, instead of the American alternative. In the past there have been requests to add…