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

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

What is a fixture?

What is a fixture?

- [Instructor] Before we moved on to write more tests, let's have a look at what a fixture is and how it can be useful for writing our tests. Pytests provides a feature called fixture. It can be useful when a constant context needs to be provided to the tests. Fixtures are created outside of the tests and can be used multiple times in different tests, or even used in other created fixtures. We will go through some examples of when it is useful later. By using fixture, you can make more complicated tests and have full control of the testing environment including setting up external environments for your tests via fixtures. Your tests can have access to these external environments that got set up. For example, you can provide information from an external process that is set up by the fixtures. So what did I mean by saying that fixtures can provide constant context from an external testing environment? Here are few examples…

Contents