# Chapter 8 pytest # filename must start with "test" # pip install pytest # pypi.org # change to working directory # ps> pytest testFileName.py --resultlog=FileName.txt # ps> pytest test_chapter8_pytest.py --resultlog=testresults.txt import pytest # pip install pytest def add(x,y): return x + y def test_addition(): result = add(2,"3") # Type Error fail int + str assert result == 5 def test_subtract(): result = 5 - 4 assert result == 1 # pass def test_multi(): result = 2 * "3" assert result == 6 # Assertion Error fail result 33 == 6 def test_div(): result = 20 / 2 assert result == 10 # pass