gvwilson / sdxpy

Software Design by Example: a tool-based introduction with Python
https://third-bit.com/sdxpy/
Other
280 stars 49 forks source link

/protocols - Section 9.1: Mock Objects (2024-01-12) #267

Closed zihanltesla closed 5 months ago

zihanltesla commented 5 months ago

Hi! I think "fakeit" can better discribe the feature of the intend here:

def fixit(name, func=None, value=None):
    assert name in globals()
    fake = Fake(func, value)
    globals()[name] = fake
    return fake

In my understanding we want exactly to replace the original function in the global environment to a fake object? Thanks!