4.6 Write a unit test using pytest

Use pytest library to write a unit test. Unit test for sample program is shown below for sample code.



from sample_fixed import AddTen

def test_answer():
  sum10 = AddTen(20)
  assert sum10.add_ten() == 30

Run the unit test and make sure all tests pass.

C:\kpurma\PythonDevelopmentProcess>python -m pytest test_sample.py
===============testsessionstarts========================
platform win32 -- Python 3.8.0, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
rootdir: C:\kpurma\PythonDevelopmentProcess
collected 1 item

test_sample.py .                                                                                                 [100%]

=======================1passedin 0.06s================