Пример #1
0
    def test_rm2(self, mock_os, mock_path):
        """
        注意 os 和 path 的顺序
        :param mock_os:
        :param mock_path:
        :return:
        """

        mock_path.isfile.return_value = False

        # test_mylib 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")
Пример #2
0
    def test_rm2(self, mock_os, mock_path):
        """
        注意 os 和 path 的顺序
        :param mock_os:
        :param mock_path:
        :return:
        """

        mock_path.isfile.return_value = False

        # test_mylib 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")
Пример #3
0
 def test_rm(self, mock_os):
     rm("any path")  # 它以为删除了某目录
     #pass
     #rm("any path")
     # test_mylib that rm called os.remove with the right parameters
     mock_os.remove.assert_called_with("any path")  # 参数传入, 但其实什么都没发生
Пример #4
0
 def test_rm(self, mock_os):
     rm("any path")  # 它以为删除了某目录
     #pass
     #rm("any path")
     # test_mylib that rm called os.remove with the right parameters
     mock_os.remove.assert_called_with("any path")  # 参数传入, 但其实什么都没发生
Пример #5
0
 def test_rm(self):
     # remove the file
     rm(self.tmpfilepath)
     # test_mylib that it was actually removed
     self.assertFalse(os.path.isfile(self.tmpfilepath), "Failed to remove the file.")
Пример #6
0
 def test_rm(self):
     # remove the file
     rm(self.tmpfilepath)
     # test_mylib that it was actually removed
     self.assertFalse(os.path.isfile(self.tmpfilepath),
                      "Failed to remove the file.")