simpledependency

An embarrassingly simple library for replacing dependencies
Download

simpledependency Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Publisher Name:
  • Benjamin Coe
  • Publisher web site:
  • https://github.com/bcoe/

simpledependency Tags


simpledependency Description

An embarrassingly simple library for replacing dependencies simpledependency is an embarrassingly simple library for replacing dependencies.simpledependency lets you globally change the behaviour of one class so that it is instantiated as a different class.Why is this good? It’s good for replacing far reaching dependencies that would screw with unit tests, e.g., make Memcached always instantiated as a faked version.Usage:Decorate the replaceable classes with the @dependency_decorator decorator.@dependency_decoratorclass Example(object): def __init__(self): print 'Example class called.'Create a replacement class, in my case this is usually a mock or fake object for unit testing.class MockExample(object): def __init__(self): print 'Mock example class called.'Actually replace the dependency.override_dependency(original_class=Example, replacement_class=MockExample) Requirements: · Python


simpledependency Related Software