python - What is a monkey patch? -
i trying understand, monkey patch?
is methods/operators overloading or delegating?
does have common these things?
no, it's not of things. it's dynamic replacement of attributes @ runtime.
for instance, consider class has method get_data. method external lookup (on database or web api, example), , various other methods in class call it. however, in unit test, don't want depend on external data source - dynamically replace get_data method stub returns fixed data.
because python classes mutable, , methods attributes of class, can as - and, in fact, can replace classes , functions in module in same way.
Comments
Post a Comment