def test_is_underage_12(self): user_input = [12] expected_output = "Enjoy your bike, kid!" with patch('builtins.input', side_effect=user_input): with patch('sys.stdout', new=StringIO()) as fake_out: target.is_underage() output = fake_out.getvalue().strip('\n') self.assertEqual(output, expected_output)
def test_is_underage_19(self): user_input = [19] expected_output = "You may smoke and drive!" with patch('builtins.input', side_effect=user_input): with patch('sys.stdout', new=StringIO()) as fake_out: target.is_underage() output = fake_out.getvalue().strip('\n') self.assertEqual(output, expected_output)