How do I run a test with pytest?

How do I run a test with pytest?

Pytest provides several options for running and selecting tests from the command line.

  1. Execute tests within a module. python test mod.py
  2. Execute tests in a directory. pytest testing/
  3. Use keyword expressions to run tests. pytest -k “MyClass and not method”
  4. Execute tests based on marker expressions. pytest -m slow
  5. Execute tests from packages.

However, if you are beginner, you can refer to this Selenium pytest tutorial.