文章目录
关键字参数
执行某个关键字的用例 : -K EXPRESSION
用例要匹配给出的表达式,使用python的语法,匹配的范围是文件名、类名、函数名为变量且用and来区分
# test.py
class TestClass(object):
def test_one(self):
a = "hi"
assert 'h' in a
def test_two(self):
a = "hello"
assert hasattr(a, 'check')
def test_three(self):
assert 0==1
运行用例:
pytest -k "test and TestClass and not test_three" test.py
执行含test、TestCase 的用例,不执行test_three的测试用例