Ejemplo n.º 1
0
    def test_path_ext(self):
        class MockInfo:
            has_path_ext = True

        env = {'PATH': '/usr/bin', 'PATHEXT': '.exe'}
        with mock.patch('bfg9000.shell.platform_info', MockInfo), \
             mock.patch('os.path.exists', side_effect=[False, True]):
            self.assertEqual(which('python', env=env), ['python'])

        with mock.patch('bfg9000.shell.platform_info', MockInfo), \
             mock.patch('os.path.exists', side_effect=[False, True]):
            self.assertEqual(which('python', env=env, resolve=True),
                             [os.path.normpath('/usr/bin/python.exe')])

        with mock.patch('bfg9000.shell.platform_info', MockInfo), \
             mock.patch('os.path.exists', side_effect=[False, True]):
            self.assertEqual(
                which([['python', '--foo']], env=env, resolve=True),
                [os.path.normpath('/usr/bin/python.exe'), '--foo'])
Ejemplo n.º 2
0
 def test_resolve(self):
     with mock.patch('os.path.exists', side_effect=[False, True]):
         self.assertEqual(which('python', env=self.env, resolve=True),
                          [os.path.normpath('/usr/local/bin/python')])
Ejemplo n.º 3
0
 def test_multiple_args(self):
     with mock.patch('os.path.exists', side_effect=[False, False, True]):
         self.assertEqual(which(['python', ['python3', '--foo']],
                                env=self.env), ['python3', '--foo'])
Ejemplo n.º 4
0
 def test_abs(self):
     with mock.patch('os.path.exists', return_value=True):
         self.assertEqual(which('/path/to/python', env=self.env),
                          ['/path/to/python'])
Ejemplo n.º 5
0
 def test_simple(self):
     with mock.patch('os.path.exists', return_value=True):
         self.assertEqual(which('python', env=self.env), ['python'])
Ejemplo n.º 6
0
 def test_multiword(self):
     with mock.patch('os.path.exists', return_value=True):
         self.assertEqual(which('python --foo', env=self.env),
                          ['python', '--foo'])