def test_rm(self): # remove the file rm(self.tmpfilepath) # test that it was actually removed self.assertFalse( os.path.isfile( self.tmpfilepath), "Failed to remove the file.")
def test_rm(self, mock_os, mock_path): # set up the mock mock_path.isfile.return_value = False rm("any path") # test that the remove call was NOT called. self.assertFalse(mock_os.remove.called, "Failed to not remove the file if not present.") # make the file 'exist' mock_path.isfile.return_value = True rm("any path") mock_os.remove.assert_called_with("any path")
def test_rm(self, mock_os, mock_path): # set up the mock mock_path.isfile.return_value = False rm("any path") # test that the remove call was NOT called. self.assertFalse(mock_os.remove.called) # make the file 'exist' mock_path.isfile.return_value = True rm("any path") mock_os.remove.assert_called_with("any path")
def test_rm(self, mock_os, mock_path): tmpfilepath = "/home/xexu/hol" # set up the mock mock_path.isfile.return_value = False rm(tmpfilepath) # test that the remove call was NOT called. self.assertFalse(mock_os.remove.called, "Failed to not remove the file if not present.") # make the file 'exist' mock_path.isfile.return_value = True rm(tmpfilepath) mock_os.remove.assert_called_with(tmpfilepath)
def test_rm(self): # remove the file rm(self.tmpfilepath) # test that it was actually removed self.assertFalse(os.path.isfile(self.tmpfilepath), "Failed to remove the file.")
def test_rm(self, mock_os): mymodule.rm("any path") # test that rm called os.remove with the right parameters mock_os.remove.assert_called_with("any path")
def test_rm(self, mock_os): rm("any path") mock_os.remove.assert_called_with("any path")