Ejemplo n.º 1
0
    def test_find_in_path(self):
        """Tests finding program in system path."""
        temp_dir = self.root
        saved_path = os.environ['PATH']
        # xxxx is not in path
        self.assertEquals('xxxx', utils.find_in_path('xxxx'))

        os.environ['PATH'] = os.environ['PATH'] + ':' + temp_dir

        open(os.path.join(temp_dir, 'xxxx'), 'w+').close()
        # xxxx is in path, but not executable.
        self.assertEquals('xxxx', utils.find_in_path('xxxx'))

        os.chmod(os.path.join(temp_dir, 'xxxx'), int(utils.EXEC_MODE))
        self.assertEquals(os.path.join(temp_dir, 'xxxx'),
                          utils.find_in_path('xxxx'))

        os.environ['PATH'] = saved_path
Ejemplo n.º 2
0
    def test_find_in_path(self):
        """Tests finding program in system path."""
        # pylint: disable=protected-access

        temp_dir = self.root
        saved_path = os.environ['PATH']
        # xxxx is not in path
        self.assertEqual('xxxx', utils.find_in_path('xxxx'))

        os.environ['PATH'] = os.environ['PATH'] + os.pathsep + temp_dir

        io.open(os.path.join(temp_dir, 'xxxx'), 'w').close()

        if os.name == 'posix':
            # xxxx is in path, but not executable.
            self.assertEqual('xxxx', utils.find_in_path('xxxx'))
            os.chmod(os.path.join(temp_dir, 'xxxx'), int(templates._EXEC_MODE))

        self.assertEqual(os.path.join(temp_dir, 'xxxx'),
                         utils.find_in_path('xxxx'))

        os.environ['PATH'] = saved_path