Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_no_permission(self, mock_remove, mock_walk):
"""Ignore if unable to delete files."""
mock_walk.return_value = self.files
cl._delete_compiled_python_files()
def test__remove_dir(self, mock_remove, mock_walk):
"""Ignore if attempt to delete a directory."""
mock_walk.return_value = self.files
cl._delete_compiled_python_files()
def test_files_not_found(self, mock_remove, mock_walk):
"""Ignore if file not found."""
mock_walk.return_value = self.files
cl._delete_compiled_python_files()
def test_delete_pyc_file(self, mock_remove, mock_walk):
"""Ensure 'pyc' files are removed."""
mock_walk.return_value = self.files
cl._delete_compiled_python_files()
mock_remove.assert_called_with(self.pyc_file_path)
def test_on_oserror(self, mock_remove, mock_walk):
"""Ignore if OSError."""
mock_walk.return_value = self.files
cl._delete_compiled_python_files()
def test_files_not_deleted(self, mock_remove, mock_walk):
"""Ensure non 'pyc' files are not removed."""
mock_walk.return_value = self.files
cl._delete_compiled_python_files()
with self.assertRaises(AssertionError):
mock_remove.assert_called_with(self.python_file_path)
with self.assertRaises(AssertionError):
mock_remove.assert_called_with(self.dot_pyc_path)