我正在尝试为密码重置流程实施集成测试,但我被困在“ password_reset_confirm ”视图中。我已经手动测试了流程,它工作正常。不幸的是,Django 单元测试客户端似乎无法正确遵循此视图中所需的重定向。
from django.contrib.auth import views as auth_views
url(r"^accounts/password_change/$",
auth_views.PasswordChangeView.as_view(),
name="password_change"),
url(r"^accounts/password_change/done/$",
auth_views.PasswordChangeDoneView.as_view(),
name="password_change_done"),
url(r"^accounts/password_reset/$",
auth_views.PasswordResetView.as_view(email_template_name="app/email/accounts/password_reset_email.html",
success_url=reverse_lazy("app:password_reset_done"),
subject_template_name="app/email/accounts/password_reset_subject.html"),
name="password_reset"),
url(r"^accounts/password_reset/done/$",
auth_views.PasswordResetDoneView.as_view(),
name="password_reset_done"),
url(r"^accounts/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$",
auth_views.PasswordResetConfirmView.as_view(
success_url=reverse_lazy("app:password_reset_complete"),
form_class=CustomSetPasswordForm),
name="password_reset_confirm"),
url(r"^accounts/reset/complete/$",
auth_views.PasswordResetCompleteView.as_view(),
name="password_reset_complete"),
Run Code Online (Sandbox Code Playgroud)
import re
from django.urls import reverse, NoReverseMatch
from django.test import TestCase, Client
from django.core import mail
from django.test.utils import override_settings
from django.contrib.auth import authenticate
VALID_USER_NAME = "username"
USER_OLD_PSW = "oldpassword"
USER_NEW_PSW = "newpassword"
PASSWORD_RESET_URL = reverse("app:password_reset")
def PASSWORD_RESET_CONFIRM_URL(uidb64, token):
try:
return reverse("app:password_reset_confirm", args=(uidb64, token))
except NoReverseMatch: …Run Code Online (Sandbox Code Playgroud) django django-forms django-views django-contrib django-authentication
我正在使用 VS Code 和 vscode-tlaplus 插件而不是 TLA+ 工具箱来学习 TLA+。现在我有了这个 TLA 文件,我在其中定义了一些常量:
---- MODULE test ----
EXTENDS TLC, Integers, Sequences
CONSTANTS Capacity, Items, ValueRange, SizeRange
ItemParams == [size: SizeRange, value: ValueRange]
ItemSets == [Items -> ItemParams]
===
Run Code Online (Sandbox Code Playgroud)
我想在 cfg 文件中设置以下内容:
SPECIFICATION Spec
CONSTANTS
SizeRange = 1..4
ValueRange = 0..3
Capacity = 7
Items = {"a", "b", "c"}
Run Code Online (Sandbox Code Playgroud)
但这会导致以下错误:
TLC threw an unexpected exception.
This was probably caused by an error in the spec or model.
See the User Output or TLC …Run Code Online (Sandbox Code Playgroud) 我正在使用 Plotly.js 绘制一些我已经知道不能为负的数据。我需要保留 Plotly 的缩放和其他绘图“导航”功能,但我不允许用户在 y 轴上低于零,因为它对绘制的数据类型没有意义。
理想情况下,[0, 100]如果可能,我希望只允许在 range 中进行缩放。
我浏览了文档和 github 问题以找到一些想法,所以我不确定当前版本的 Plotly 是否可能满足我的需求。
有任何想法吗?
谢谢