1. You can stop the test when N failures occur

Pytest-x: stop pytest when the first failure occurs — maxFail =2

2. Pytest can be run in a variety of ways and optionally in command line mode

  • Pytest test_mod.py runs this file (module)
  • Pytest Testing/Runs the test files in the specified directory

3. Specify the specific method of the specific class in the run file. Use :: to separate the file, class, and method

pytest test_mod.py::TestClass::test_method

4. Pytest also provides a main() function to execute test cases

import pytest def test_main(): assert 5 ! = 5 if __name__ == '__main__': pytest.main()Copy the code

Sublime, CTRL + B can be run

5. Run the specified directory file under main()

import pytest def test_main(): assert 5 ! = 5 if __name__ = = "__main__ ': pytest. The main (" d: / pyse pytest/") # test directory specifiedCopy the code