Exemple #1
0
 def test_display_total(self, mock_print):
     timesheets.display_total(123)
     mock_print.assert_called_once_with('Total hours worked: 123')
Exemple #2
0
 def test_display_total(
     self, mock_print
 ):  # Again self is the first arguement, since this is a method in a class, we need another arguement which is the mock object
     timesheets.display_total(123)
     # How do we know the right thing was printed? we do that by replacing the regular print function with the mock. Basically calls the mock print instead of the the built-in print
     mock_print.assert_called_once_with('Total hours worked: 123')