FIX Bug 347 #215

Closed
dengbo wants to merge 1 commits from Bug585-Xuhaoxuan into Alpha-snapshot20240618
There is no content yet.
dengbo added 1 commit 2025-06-19 13:10:23 +08:00
dengbo changed title from WIP: FIX Bug 347 to FIX Bug 347 2025-06-19 13:10:47 +08:00
huangkeqing changed title from FIX Bug 347 to FIX Bug 347 2025-06-24 14:23:23 +08:00
huangkeqing requested changes 2025-06-24 14:23:40 +08:00
@ -31,3 +31,2 @@
// 基本表单验证
if (username === "" || password === "" || password2 === "") {
alert('输入不能为空!');
if (password === "" || password2 === "") {

在用户注册时,缺失对于用户名为空的判断

在用户注册时,缺失对于用户名为空的判断
@ -0,0 +37,4 @@
assert f'{c} is not allowed' in result, f"Failed on char: {c}"
def test_username_uses_restricted_word():

对于保留字的判断,需要覆盖大小写不敏感的情况。可以修改受限词列表,包含不同大小写形式(例如,对于每个词,我们不仅测试小写,还测试大写、首字母大写等)。

对于保留字的判断,需要覆盖大小写不敏感的情况。可以修改受限词列表,包含不同大小写形式(例如,对于每个词,我们不仅测试小写,还测试大写、首字母大写等)。
yuyexuan scheduled this pull request to auto merge when all checks succeed 2025-06-25 12:44:17 +08:00
yuyexuan canceled auto merging this pull request when all checks succeed 2025-06-25 12:44:33 +08:00
yuyexuan closed this pull request 2025-06-25 12:44:41 +08:00
yuyexuan approved these changes 2025-06-25 12:46:05 +08:00
@ -79,6 +79,8 @@ class UserName:
def validate(self):

这段代码缺少对特殊字符(如@, #, $等),未处理Unicode字符和不可见字符的全面检查

这段代码缺少对特殊字符(如@, #, $等),未处理Unicode字符和不可见字符的全面检查
@ -0,0 +5,4 @@
import os
# 获取文件所在目录的上两级目录EnglishPal
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))

根目录获取用pathlib方式更加简洁高效
应明确导入路径而不是模糊的from app.Login import

根目录获取用pathlib方式更加简洁高效 应明确导入路径而不是模糊的from app.Login import
@ -0,0 +61,4 @@
get_user_by_username = original_get_user_by_username
def test_add_user_with_empty_username_fails():

在test_add_user_with_empty_username_fails和test_add_user_with_valid_username_succeeds中有如下的问题:assert result is None 没有明确表达测试意图,没有直接验证是否调用了数据库插入方法
那么我们可以使用pytest-mock的方式简化代码,提高测试效率

在test_add_user_with_empty_username_fails和test_add_user_with_valid_username_succeeds中有如下的问题:assert result is None 没有明确表达测试意图,没有直接验证是否调用了数据库插入方法 那么我们可以使用pytest-mock的方式简化代码,提高测试效率
@ -0,0 +45,4 @@
assert 'restricted word' in result, f"Failed on word: {word}"
def test_username_contains_chinese():

中文用户名测试不明确,仅测试了纯中文字符,未测试混合情况
错误信息断言过于具体,可能随需求变化而失效

中文用户名测试不明确,仅测试了纯中文字符,未测试混合情况 错误信息断言过于具体,可能随需求变化而失效

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mrlan/EnglishPal#215
There is no content yet.