Esempio 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'])
Esempio 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')])
Esempio 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'])
Esempio 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'])
Esempio n. 5
0
 def test_simple(self):
     with mock.patch('os.path.exists', return_value=True):
         self.assertEqual(which('python', env=self.env), ['python'])
Esempio 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'])