AI engineering glossary · Python advanced
What is fixture?
Fixture: A reusable piece of setup, and optional teardown, that pytest supplies to tests by name through function arguments. It provides things such as sample data, database connections or temporary files.
Fixture: an example
@pytest.fixture def sample_df(): return pd.DataFrame(...) then def test_x(sample_df): receives that data.
Related terms
More Python advanced terms
- functools
- functools.lru_cache
- functools.partial
- functools.wraps
- Future
- Generator
- Generator expression
- Generic
Where you learn it
Fixture is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.