testing/example_scripts/acceptance/fixture_mock_integration.py
raw| 1 | # mypy: allow-untyped-defs |
| 2 | """Reproduces issue #3774""" |
| 3 | |
| 4 | from __future__ import annotations |
| 5 | |
| 6 | from unittest import mock |
| 7 | |
| 8 | import pytest |
| 9 | |
| 10 | |
| 11 | config = {"mykey": "ORIGINAL"} |
| 12 | |
| 13 | |
| 14 | @pytest.fixture(scope="function") |
| 15 | @mock.patch.dict(config, {"mykey": "MOCKED"}) |
| 16 | def my_fixture(): |
| 17 | return config["mykey"] |
| 18 | |
| 19 | |
| 20 | def test_foobar(my_fixture): |
| 21 | assert my_fixture == "MOCKED" |