Let’s say we have a Python module with a constant variable or a function decorator on a function we want to test. Those statements are initialized when a module is imported, how can we test them? How can we change them on a test by test basis? In this post, I’m going to show different ways to mock Python module statements.