From the course: Create an Open-Source Project in Python

Unlock the full course today

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

Using fixture

Using fixture - Python Tutorial

From the course: Create an Open-Source Project in Python

Start my 1-month free trial

Using fixture

- Now that we know what a fixture is let's use it in a very simple scenario. As usual, we start editing our tests. Now let's see what we can change into a fixture. What do you think? Something that is constant and can be reused in other tests. Okay, let's see if you are thinking the same. We are going to make the task list in test find task into a fixture so we can reuse it in other tests. First, remember that we will post the fixture in as a parameter. So let's add that in the parameter list for test find task. Then we write the fixture like this. Let's edit before the test function. If you feel like a challenge, post a video and try writing it yourself before watching me doing it. (energetic music) (typing) Also, don't forget to delete the test list in the test function since we don't need it any longer. Now, let's test if it still works. Okay, like you did before. So save and quit. Let's test it out (typing)…

Contents