We will learn how to execute single test file and multiple test files. We already have a test file test_square.py created. Create a new test file test_compare.py with the following code −
# test_compare.py
def test_greater():
num = 100
assert num > 100
def test_greater_equal():
num = 100
assert num >= 100
def test_less():
num = 100
assert num < 200
Now to run all the tests from all the files (2 files here) we need to run the following command −
pytest -v
To execute the tests from a specific file, use the following syntax −
pytest <filename> -v
Now, run the following command −
pytest test_compare.py -v