Collected 0 items appear when pytest runs

1. Check whether the naming format is standard

  1. .py files must start with test_ (or end with _test)
  2. The test class must start with Test and cannot have an init method
  3. The test method must start with test_
  4. Assert must use assert

2. Has the .py file changed its name?
Share the pit that you just stepped on: as shown in the figure, the
file and function naming are in compliance with the specification, but the operation prompts collected 0 items, which is puzzled. After Baidu N times, it is finally solved.
Reason: The file name has been modified. After the file is written, if you modify the file name, the subsequent code cannot be recorded in this file, so you need to rewrite the code (re-copy should also work), pay attention to the next time the file is created, it is best to have the name in place at once, and do not follow Feel free to change. After rewriting, it can run normally.

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_35708058/article/details/112757702