Challenge 2: A Fixture for Shared Test Data — Possible Solution ==================================================================== import pytest @pytest.fixture def sample_scores(): return [85, 90, 78, 92] def test_average(sample_scores): assert sum(sample_scores) / len(sample_scores) == 86.25 def test_max(sample_scores): assert max(sample_scores) == 92 Running: pytest test_scores.py Output: test_scores.py::test_average PASSED test_scores.py::test_max PASSED WHY THIS WORKS AS AN ANSWER ------------------------------ @pytest.fixture above def sample_scores(): reuses the chapter's own sample_list fixture example exactly — a function decorated with @pytest.fixture whose return value becomes available to any test that asks for it. Both test_average(sample_scores) and test_max(sample_scores) reuse this chapter's fixture-injection mechanism: because each test function has a parameter named sample_scores — matching the fixture's name exactly — pytest automatically calls the fixture and passes its return value in, the same "injected by matching parameter name" behavior demonstrated with test_sum(sample_list) and test_length(sample_list). sum(sample_scores) / len(sample_scores) reuses the average-of-a-list pattern from earlier chapters' challenges to compute 86.25 from [85, 90, 78, 92]. max(sample_scores) reuses the built-in max() function to confirm 92 is the largest value. Using one shared fixture instead of retyping [85, 90, 78, 92] inside both test functions is the entire point of a fixture: if the sample data ever needs to change, there's exactly one place to update it, and every test using it stays in sync automatically.