test_ok1/testing/example_scripts/acceptance/fixture_mock_integration.py

21 lines
343 B
Python
Raw Normal View History

"""Reproduces issue #3774"""
try:
import mock
except ImportError:
import unittest.mock as mock
import pytest
config = {"mykey": "ORIGINAL"}
@pytest.fixture(scope="function")
@mock.patch.dict(config, {"mykey": "MOCKED"})
def my_fixture():
return config["mykey"]
def test_foobar(my_fixture):
assert my_fixture == "MOCKED"