10/11/2019 - 5:34 PM

Creating a basic test in pytest

Creates a demo test in pytest

# in a file called '':
def last_digit(n1, n2):
        Define a function that takes in two non-negative integers a and b and 
        returns the last decimal digit of a^b
    return pow(n1, n2, 10)

# in a file called '':

import pytest
from digits import last_digit

def test_last_digit():
  assert last_digits(8, 2) == 4
  assert last_digits(3, 2) == 9

# running a test:
# in the command line type python -m pytest

	Putting the tests in a subdirectory causes import issues (need to learn how to import from one directory above)
	Not running pytest as a python module (python -m) causes name errors and import errors because it does not know where the python 	 path is for some reason