我正在尝试使用selenium for python为我的django应用程序编写简单的登录测试,但是我收到凭据无效的错误。对于注册,我使用allauth包提供电子邮件确认机制。据我所知,凭据无效,因为新创建的用户没有回复确认电子邮件。有没有办法将其关闭以进行测试?我试图将ACCOUNT_EMAIL_REQUIRED设置为False,但它导致断言(这是runserver命令的结果):
Unhandled exception in thread started by <function check_errors. <locals>.wrapper at 0x7fccbb8cb400>
Traceback (most recent call last):
File "/pathToPython/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/pathToPython/python3.5/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "/pathToPython/python3.5/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/pathToPython/python3.5/site-packages/django/core/management/__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "/pathToPython/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/pathToPython/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/pathToPython/python3.5/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/pathToPython/python3.5/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/pathToPython/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/pathToPython/python3.5/site-packages/allauth/account/models.py", line 12, in <module>
from . import app_settings, signals
File "/pathToPython/python3.5/site-packages/allauth/account/app_settings.py", line 328, in <module>
app_settings = AppSettings('ACCOUNT_')
File "/pathToPython/python3.5/site-packages/allauth/account/app_settings.py", line 22, in __init__
self.AuthenticationMethod.EMAIL) or self.EMAIL_REQUIRED
AssertionError
出于测试目的,我使用filebased.EmailBackend所以我考虑在测试中使用一些功能,这将注册用户然后找到这个日志模仿确认电子邮件并访问其中指定的网站,但也许有人知道更好的解决方案?
答案 0 :(得分:0)
万一有人在找它-allauth有一个名为account_addressemail的表,该表存储了已更改的参数。当用户单击验证电子邮件中的“确认”按钮时,其设置为True,因此在测试中,只需手动设置即可。