3 Star 5 Fork 0

段友甲/垃圾分类系统

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
黑盒测试.py 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
段友甲 提交于 2024-06-16 18:02 . update 黑盒测试.py.
import unittest
class TestUserRegistration(unittest.TestCase):
def test_username_validation(self):
# Valid equivalence classes for username
valid_usernames = ["user123", "username", "testuser", "123456789012"]
# Invalid equivalence classes for username
invalid_usernames = ["u", "user1234567890", "username1234567890"]
for username in valid_usernames:
self.assertTrue(validate_username(username))
for username in invalid_usernames:
self.assertFalse(validate_username(username))
def test_password_validation(self):
# Valid equivalence classes for password
valid_passwords = ["Password1", "SecurePwd123", "12345678aA", "Abcdefg12345678"]
# Invalid equivalence classes for password
invalid_passwords = ["password", "12345678", "Abcdefghijklmnop", "12345678901234567"]
for password in valid_passwords:
self.assertTrue(validate_password(password))
for password in invalid_passwords:
self.assertFalse(validate_password(password))
# Function to validate username
def validate_username(username):
# Check if username length is between 6 to 12 characters
if 6 <= len(username) <= 12:
return True
else:
return False
# Function to validate password
def validate_password(password):
# Check if password length is between 8 to 16 characters
if not (8 <= len(password) <= 16):
return False
# Check if password contains both letters and numbers
has_digit = any(char.isdigit() for char in password)
has_alpha = any(char.isalpha() for char in password)
if has_digit and has_alpha:
return True
else:
return False
if __name__ == '__main__':
unittest.main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/duan-youjia/garbage-classification-system.git
git@gitee.com:duan-youjia/garbage-classification-system.git
duan-youjia
garbage-classification-system
垃圾分类系统
master

搜索帮助