def test_is_mailbox(self, mailbox, result): """ 第一种:只允许英文字母、数字、下划线、英文句号、以及中划线组成 第二种:名称允许汉字、字母、数字,域名只允许英文域名 二种中任何一种即可 """ assert xstring.check(mailbox).is_mailbox == result
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/3/17 17:27 # @Author : 熊利宏 # @project : 直接测试模块 # @Email : [email protected] # @File : test.py # @IDE : PyCharm # @REMARKS : 直接测试xtoolkit库的各项模块 import arrow from dateutil.parser import parse # 时间字符串解析 from datetime import datetime, date import time from xToolkit.xdatetime.xdatetime.xdatetime import UTC8 from xToolkit import xstring, xdatetime if __name__ == "__main__": print(xstring.check(15172383635).is_phone)
def test_is_phone(self, phones, result): """ 第一位为1,一共11位数字 """ assert xstring.check(phones).is_phone == result
def test_is_url(self, urls, result): assert xstring.check(urls).is_url == result
def test_is_int(self, ints, result): assert xstring.check(ints).is_int == result
def test_datetime_string(self, times, result): assert xstring.check(times).is_datetime_string == result
def test_identity_card(self, identity, result): assert xstring.check(identity).is_identity_card == result
def test_car_number(self, car, result): assert xstring.check(car).is_car_number == result
def test_check_no(self): with pytest.raises(ValueError) as example: xstring.check().is_identity_card() assert str(example.value) == "check() 方法暂时只支持一个参数并且不能为空"
def test_is_user_password(self, passwords, result): """ 包含6-18位字符,必须包含字母与数字,可以包含特殊字符 """ assert xstring.check(passwords).is_user_password == result
def test_is_user_name(self, names, result): """ 姓名要求为2-4个中文 """ assert xstring.check(names).is_user_name == result
def test_is_bank_number(self, banks, result): """ 第一位不能为0,并且13到19位数字 """ assert xstring.check(banks).is_bank_number == result