Testing django

34 views
Skip to first unread message

Ayush Bisht

unread,
Mar 16, 2023, 3:24:27 PM3/16/23
to Django users
./runtests.py --settings=path.to.settings i18n.tests.TranslationTests

what exactly is the purpose of path.to.settings, I'm getting an error while running the above line.
Can anyone please explain?

Error  
Testing against Django installed in '/home/ayush/OS/django/django' with up to 8 processes
Traceback (most recent call last):
  File "/home/ayush/OS/django/tests/./runtests.py", line 770, in <module>
    failures = django_tests(
  File "/home/ayush/OS/django/tests/./runtests.py", line 398, in django_tests
    test_labels, state = setup_run_tests(*process_setup_args)
  File "/home/ayush/OS/django/tests/./runtests.py", line 300, in setup_run_tests
    test_modules, state = setup_collect_tests(
  File "/home/ayush/OS/django/tests/./runtests.py", line 201, in setup_collect_tests
    "INSTALLED_APPS": settings.INSTALLED_APPS,
  File "/home/ayush/OS/django/django/conf/__init__.py", line 84, in __getattr__
    self._setup(name)
  File "/home/ayush/OS/django/django/conf/__init__.py", line 71, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/ayush/OS/django/django/conf/__init__.py", line 185, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'path'

Ayush Bisht

unread,
Mar 16, 2023, 3:30:01 PM3/16/23
to Django users
Seems like, it is for defining how actually we are selecting the specific test case. It is very confusing at first. 
Can't we just explain it with an example..

Bhuvnesh Sharma

unread,
Mar 16, 2023, 3:50:32 PM3/16/23
to django...@googlegroups.com
We can run django tests with custom settings by using --settings flag and providing the path to the custom settings file . For example:
./runtests.py --settings=new_app.test_settings

What do you want to do exactly?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd827ca8-704e-4ffc-8d7a-2c56d100cdd7n%40googlegroups.com.

Ayush Bisht

unread,
Mar 16, 2023, 4:42:42 PM3/16/23
to django...@googlegroups.com
Yeah, I got you.. 
My concern is on the documentation, the way it has provided the commands for executing test cases. 

That 
path.to.settings seems confusing sometimes.. 

Reply all
Reply to author
Forward
0 new messages