pytest basic usage

1, with the assertion assert, can be ==,! =, +, -, *, /, <=,> =, True, False, is True, is not True, in, not in determining the like.

 

2, test functions and the test file must " Test beginning" test class must ' the Test beginning'.

3, () test method performed by main. Need to specify the path and parameters, you can also specify a test class or test method " :: separated." Such as:

 

pytest.main(['-s','./test_fixtures_01.py::test_multiply_5_6'])

 

4, Pytest provides a rich operating parameters test, '- s': Close capture, output print information. '-v': for increasing a lengthy test case. '-k'  : run a test case of a string. Such as: pytest add XX.py -krepresents add operation XX.py contained test case. 'q': reduce long runs test. '-x': a test case fails to appear exit the test. Very useful during the commissioning phase, when the test results in failure, debugging through, rather than continuing to execute test cases. pytest can also run the test directory: pytest directory 

5、

 

 

 

Guess you like

Origin www.cnblogs.com/wzjbg/p/11618515.html