From the course: Unit Testing in Python

Unlock the full course today

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

Challenge: Parametrization

Challenge: Parametrization - Python Tutorial

From the course: Unit Testing in Python

Start my 1-month free trial

Challenge: Parametrization

(upbeat music) - [Instructor] Alright, now it's your turn. Here's a challenge for you to complete. We have another test called test_csv_writer. I would like you to update it to be parameterized with the following three scenarios. Moving to the IDE, let's check out the test as it is written now in test_param_challenge.py on line 29. On line 44, further down in this test, it uses a data aggregator to load the median statistic for Andorra. And then, on line 46, it writes the data to a csv. To focus this test on functionality, it is writing to string IO rather than an actual location on disk. On line 48, we get the value written and finally assert that it is what we expect on line 49. Please refactor this test so it can be run over the three scenarios commented out on line 32 through 34. Here's one hint. In the final assertion, you will need to inject the arguments applied to the function to replace certain parts of the…

Contents