title: Django channels pytest testing. django.core.exceptions.ImproperlyConfigured. .
body: <p>I am getting this error when running pytest. I am following this tutorial: <a href="https://channels.readthedocs.io/en/latest/topics/testing.html" rel="noreferrer">https://channels.readthedocs.io/en/latest/topics/testing.html</a></p>
  
  <pre><code>django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
  </code></pre>
  
  <p>The following the things I've tried:</p>
  
  <ul>
  <li>place django.conf.settings.configure() at the top of the test script</li>
  <li><p>place the following code at the top of the test script</p>
  
  <p>ROOT_DIR = environ.Path(<strong>file</strong>) - 2</p>
  
  <p>env = environ.Env()</p>
  
  <p>env_file = str(ROOT_DIR.path('.env'))</p>
  
  <p>env.read_env(env_file)</p></li>
  </ul>