From the course: Testing Python Data Science Code
Unlock the full course today
Join today to access over 25,200 courses taught by industry experts.
Parametrized tests - Python Tutorial
From the course: Testing Python Data Science Code
Parametrized tests
- [Instructor] In some cases you'd like to run the same test on several inputs. In pytest, this is known as parametrized test. Let's look at an example. Let's say we have our scaling function and we'd like to test it. So in our test, we going to create a vector and then several test cases for the vector with this cutoff and this scaling factor, this should be the output, another one with the maximum value, et cetera, et cetera. And now we can do pytest mark parameterized. We give a string with a list of parameters name. This parameters names must match the actual parameters to the testing function. And we say, "Use the scale cases to feed this function." When we are going to run the test, it is going to pass. And if you look at our test scale you see that we're actually seeing two different tests. Each test case is considered a separate test. The same way goes if you run it from the command line, Python dash M, pytest dash…