Monkey Patching dictionary items - Fixtures and Mocking in Python
Keyboard shortcuts
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Monkey Patching dictionary items
data = {
'name' : 'foo',
'age' : 42
}
import aut
def test_a():
assert aut.data == {
'name' : 'foo',
'age' : 42
}
def test_b(monkeypatch):
monkeypatch.setitem(aut.data, 'name', 'bar')
assert aut.data == {
'name' : 'bar',
'age' : 42
}
def test_c():
assert aut.data == {
'name' : 'foo',
'age' : 42
}