Test Fixtures

Setup and teardown

Interview Relevant: Test organization

Fixtures

Reliable way to setup state for tests.

Code Examples

python
1import pytest
2
3@pytest.fixture
4def data():
5    return [1, 2, 3]
6
7def test_sum(data):
8    assert sum(data) == 6

AI Tutor

Ask about the topic

Sign in Required

Please sign in to use the AI tutor

Sign In