How to use test_pytest method in gabbi

Best Python code snippet using gabbi_python

test_pytest.py

Source:test_pytest.py Github

copy

Full Screen

1# pytest测试框架2import pytest3def func(x):4 return x + 15# 参数化6@pytest.mark.parametrize('a,b', [7 (1, 2),8 (10, 20),9 ('a', 'a1'),10 (3, 4),11 (5, 6)12])13def test_answer(a, b):14 assert func(a) == b15def test_answer1():16 assert func(4) == 517# 装饰器18@pytest.fixture()19def login():20 print('登录操作')21 username = 'chan'22 return username23class TestDemo:24 def testa(self):25 print('a')26 # test_a需要提前登录,就传入login,在执行测试用例前会先执行login方法27 def test_a(self, login):28 print(f' username = {login}')29 def test_b(self):30 print('b')31 def test_c(self, login):32 print(f'c username = {login}')33if __name__ == '__main__':34 # pytest.main(['test_pytest.py'])35 # 相当于命令号执行 python test_pytest.py36 # pytest.main(['test_pytest.py::test_answer1','-v'])37 # pytest.main(['test_pytest.py::TestDemo','-v'])38 pytest.main(['test_pytest.py::TestDemo::test_b', '-v'])39 # 在terminal中执行python test_pytest.py查看,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run gabbi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful