From the course: Unit Testing in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Parameterization

Solution: Parameterization - Python Tutorial

From the course: Unit Testing in Python

Start my 1-month free trial

Solution: Parameterization

(upbeat music) - [Instructor] Let's walk through the solution. First, we can use the pytest parametrize decorator and append it to the top of our test as shown on line 29. Next, we define three arguments: country, stat, and expected, which we will use within our test function. Then, we should create a list with Tuple entries. Each Tuple entry on lines 30 through 32 defines one of the three given test scenarios. We must make sure to update the decorators to find attributes as our function arguments. This is done on line 34. Now we must move on to change other contents of this function. For example, on line 36 which is aggregating our data into a statistic, we need to sub out the hard-coded country and the stat for our country and stat argument. Then on line 41, we substitute stat, country, and expected into the final string. This will be used to check if the retrieved csv data was written correctly. Now that you've…

Contents