title: django - how to detect test environment (check / determine if tests are being run)
body: <p>How can I detect whether a view is being called in a test environment (e.g., from <code>manage.py test</code>)?</p>
  <pre><code>#pseudo_code
  def my_view(request):
      if not request.is_secure() and not TEST_ENVIRONMENT:
          return HttpResponseForbidden()
  </code></pre>