title: python: mock a module
body: <p>Is it possible to mock a module in python using <code>unittest.mock</code>? I have a module named <code>config</code>, while running tests I want to mock it by another module <code>test_config</code>. how can I do that ? Thanks.</p>
  
  <p>config.py:</p>
  
  <pre><code>CONF_VAR1 = "VAR1"
  CONF_VAR2 = "VAR2"
  </code></pre>
  
  <p>test_config.py:</p>
  
  <pre><code>CONF_VAR1 = "test_VAR1"
  CONF_VAR2 = "test_VAR2" 
  </code></pre>
  
  <p>All other modules read config variables from the <code>config</code> module. While running tests I want them to read config variables from <code>test_config</code> module instead.</p>