Exemple #1
0
 def test_find_executable(self):
     with patch('os.path.isfile', Mock(return_value=True)):
         self.assertEqual(find_executable('vim'), 'vim.exe')
     with patch('os.path.isfile', Mock(return_value=False)):
         self.assertIsNone(find_executable('vim'))
     with patch('os.path.isfile', Mock(side_effect=[False, True])):
         self.assertEqual(find_executable('vim', '/'), '/vim.exe')
 def validate(self, name):
     if not name:
         yield Result(False, "is an empty string")
     elif not os.path.exists(name):
         yield Result(False, "Directory '{}' does not exist.".format(name))
     elif not os.path.isdir(name):
         yield Result(False, "'{}' is not a directory.".format(name))
     else:
         if self.contains:
             for path in self.contains:
                 if not os.path.exists(os.path.join(name, path)):
                     yield Result(
                         False,
                         "'{}' does not contain '{}'".format(name, path))
         if self.contains_executable:
             for program in self.contains_executable:
                 if not find_executable(program, name):
                     yield Result(
                         False,
                         "'{}' does not contain '{}'".format(name, program))