# pytest # pip install pytest > to install the pytest module # run tests from command line pytest filename.py # pip install pytest-mock for mocking input() prompts from OrderSystem import Contact, Order def get_name_and_email(): i_name = input("Enter your name: ") i_email = input("Enter your email: ") return i_name, i_email # use prefix test_ on all testing for pytest def test_contact_creation(mocker): # single property test #mocker.patch('builtins.input', return_value="Bob Smith") # multiple prop test mocker.patch('builtins.input', side_effect=['Bob Smith','bob@1234.com']) i_name, i_email = get_name_and_email() # param1, param2 from the return keyword > return i_name, i_email contact = Contact(i_name, i_email) assert contact.name == i_name assert contact.email == i_email def test_order_creation(): contact = Contact("Bob Smith", "bob@1234.com") order = Order(1234, contact) #self.assertEqual(order.order_id, 1234) > unittesting #self.assertEqual(order.contact, contact) > unittesting assert order.order_id == 1234 # pytest assert order.contact == contact # pytest def test_myCalc(): x = 7 y = 3 z = x + y assert z == 10