Fuzz-testing Django application with atheris

46 views Asked by At

I'm running my Django-project:

cd PycharmProjects/Autopark
source venv/bin/activate
python3 manage.py runserver

This is insides of project's wsgi.py:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'autopark.settings')
application = get_wsgi_application()

After that I open another tab of my terminal (I'm using Linux Mint) and start my fuzz-test script via the same venv:

source venv/bin/activate
python3 fuzz_test1.py

That's first few strings from that file:

import os
import django
django.setup()

from django.test import Client
client = Client()

And I have an error at django.setup():

Traceback (most recent call last):
  File "/home/paberu/PycharmProjects/Autopark/fuzz_test1.py", line 4, in <module>
    django.setup()
  File "/home/paberu/PycharmProjects/Autopark/venv/lib/python3.10/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/home/paberu/PycharmProjects/Autopark/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__
    self._setup(name)
  File "/home/paberu/PycharmProjects/Autopark/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 72, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I don't have any idea of what am I doing wrong. Can you help me get rid of that error?

0

There are 0 answers