Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 731 Bytes

2._file_execution.md

File metadata and controls

38 lines (26 loc) · 731 Bytes

File Execution

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