pytest -s test_command_param.py -m=webtest\ pytest -s test_command_param.py -m apptest\ pytest -s test_command_param.py -m “not ios”
import pytest
def double(a):
return a * 2
# 测试数据:整型
@pytest.mark.int
def test_double_int():
print("test double int")
assert 2 == double(1)
# 测试数据:负数
@pytest.mark.minus
def test_double_minus():
print("test double minus")
assert -2 == double(-1)
# 测试数据:浮点数
@pytest.mark.float
def test_double_float():
print("test double float")
assert 0.2 == double(0.1)
@pytest.mark.float
def test_double2_minus():
print("test double float")
assert -10.2 == double(0.2)
@pytest.mark.zero
def test_double_0():
assert 10 == double(0)
@pytest.mark.bignum
def test_double_bignum():
assert 200 == double(100)
@pytest.mark.str
def test_double_str():
assert 'aa' == double('a')
@pytest.mark.str
def test_double_str1():
assert 'a$a$' == double('a$')
这是pytest的内置标签,可以处理一些特殊的测试用例,不能成功的测试用例等
skip:始终跳过该测试用例。采用添加装饰器@pytest.mark.skip,或者添加跳过代码pytest.skip(reason)等两种方式。
skipif:遇到特定情况,跳过该测试用例。采用添加装饰器@pytest.mark.skipif的方式。
xFail:遇到特定情况,产生一个“期望失败”的输出。采用添加装饰器@pytest.mark.xfail,或者添加跳过代码pytest.xfail(reason)等两种方式。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。