Я выполняю один конкретный тест через PyCharm (ctrl-shift-F10).
Я получаю эту ошибку:
Testing started at 18:12 ...
/home/guettli/simple21env/bin/python /snap/pycharm-community/188/plugins/python-ce/helpers/pycharm/_jb_unittest_runner.py --target simple21.tests.TermTests.test_str_of_sub_term
Launching unittests with arguments python -m unittest simple21.tests.TermTests.test_str_of_sub_term in /home/guettli/simple21env/src/simple21tree
Traceback (most recent call last):
File "/snap/pycharm-community/188/plugins/python-ce/helpers/pycharm/_jb_unittest_runner.py", line 35, in <module>
main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not JB_DISABLE_BUFFERING)
File "/usr/lib/python3.6/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/usr/lib/python3.6/unittest/main.py", line 141, in parseArgs
self.createTests()
File "/usr/lib/python3.6/unittest/main.py", line 148, in createTests
self.module)
File "/usr/lib/python3.6/unittest/loader.py", line 219, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python3.6/unittest/loader.py", line 219, in <listcomp>
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName
module = __import__(module_name)
File "/home/guettli/simple21env/src/simple21tree/simple21/tests.py", line 7, in <module>
from . import views
File "/home/guettli/simple21env/src/simple21tree/simple21/views.py", line 5, in <module>
from simple21.models import Term, SearchLog, GlobalConfig
File "/home/guettli/simple21env/src/simple21tree/simple21/models.py", line 1, in <module>
from django.contrib.auth.models import User
File "/home/guettli/simple21env/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/guettli/simple21env/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/home/guettli/simple21env/lib/python3.6/site-packages/django/db/models/base.py", line 107, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/guettli/simple21env/lib/python3.6/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "/home/guettli/simple21env/lib/python3.6/site-packages/django/apps/registry.py", line 135, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Process finished with exit code 1
Empty suite
Я думаю, мне нужно позвонить django .setup () .
Нет ли способа избежать записи django.setup()
в каждый python тестовый файл?
Запуск теста из командной строки работает. Этот вопрос касается вызова одного конкретного теста непосредственно из PyCharm.