title: How to patch a constant in python
body: <p>I have two different modules in my project. One is a config file which contains</p>
  
  <pre><code>LOGGING_ACTIVATED = False
  </code></pre>
  
  <p>This constant is used in the second module (lets call it main) like the following:</p>
  
  <pre><code>if LOGGING_ACTIVATED:
      amqp_connector = Connector()
  </code></pre>
  
  <p>In my test class for the main module i would like to patch this constant with the value</p>
  
  <pre><code>True
  </code></pre>
  
  <p>Unfortunately the following doesn't work</p>
  
  <pre><code>@patch("config.LOGGING_ACTIVATED", True)
  </code></pre>
  
  <p>nor does this work:</p>
  
  <pre><code>@patch.object("config.LOGGING_ACTIVATED", True)
  </code></pre>
  
  <p>Does anybody know how to patch a constant from different modules?</p>