Python test frameworks generally do mocking by monkey-patching, and they take care of it for you. This does not generally require global state, either in the form of module-level variables or singletons. It works by doing things like replacing the attributes of an existing class or module object. (Python takes "everything is an object" seriously, so a module is an object whose attributes are the functions, classes and other global variables of the corresponding file's code, roughly speaking. It is not simply reflected as such through a reflection API, like in Java; it is directly represented with an object. This is the sort of benefit dynamic typing gets you, along with the object-qua-dictionary-of-attributes model.)