From the course: Create an Open-Source Project in Python
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
What is a fixture? - Python Tutorial
From the course: Create an Open-Source Project in Python
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
-
-
-
-
What is pytest?1m 57s
-
(Locked)
Introduction to your project2m 35s
-
(Locked)
Writing simple tests3m 51s
-
(Locked)
Testing with multiple parameters4m 17s
-
(Locked)
Test if an exception is raised2m 41s
-
(Locked)
What is a fixture?3m 18s
-
(Locked)
Using fixture2m 38s
-
(Locked)
Skipping a test, with good reasons3m 17s
-
(Locked)
Checkpoint: What you have so far2m 1s
-
-
-
-
-