pytest discover the test by its standard convention. Below are the standard conventions,
Files - test_*.py or *_test.py files
Functions or Method - test_ prefixed test functions or methods outside of class
Class - Test_ prefixed test classes
test_sample.py
def test_01():
assert 5==5
You can execute the pytest test in different ways,
If you are using Pycharm to create and maintain your test, you can follow the below steps to execute the test
Once the test_sample.py file and test_01 function is created.
You can run your pytest test using below command,
pytest [options] [file_or_dir] [file_or_dir]
Also pytest provides plenty of command line options to select and run the test.
Refer Command line Options
pytest look for pytest.ini, tox.ini and setup.cfg configuration file to execute the test.
[pytest]
python_files =
test_sample.py