title: Environment variables with pytest and tox
body: <p>How can I test environment variables using pytest and tox?</p>
  <h1>validate.py</h1>
  <pre><code>ENV_VAR = os.environ['ENV_VAR']
  
  def validate_env_var(value):
      if value != ENV_VAR:
          raise Exception
  </code></pre>
  <h1>test_validate.py</h1>
  <pre><code>class TestValidateEnvVar:
      def test_validate_env_var_pass(self):
          value = 'valid_env_value'
          os.environ[&quot;ENV_VAR&quot;] = value
          validate.validate_env_var(value)
  </code></pre>
  <p>If I set the environment variables in the <code>tox.ini</code> file:</p>
  <pre><code>[testenv]
  setenv = ENV_VAR=valid_env_value
  </code></pre>
  <p>The test passes, but I would like to keep the test isolated.</p>