2016-11-06 15:50:37 -05:00
|
|
|
# Copyright (C) 2016-2017 YouCompleteMe contributors
|
2016-01-12 15:24:23 -05:00
|
|
|
#
|
|
|
|
# This file is part of YouCompleteMe.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# YouCompleteMe is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-02-27 19:12:24 -05:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import absolute_import
|
2017-03-09 09:57:27 -05:00
|
|
|
# Not installing aliases from python-future; it's unreliable and slow.
|
2016-02-27 19:12:24 -05:00
|
|
|
from builtins import * # noqa
|
|
|
|
|
2016-10-14 05:00:57 -04:00
|
|
|
from ycm.tests.test_utils import MockVimModule
|
2016-01-12 15:24:23 -05:00
|
|
|
MockVimModule()
|
|
|
|
|
|
|
|
from nose.tools import ok_
|
2016-11-06 15:50:37 -05:00
|
|
|
from ycm.paths import _EndsWithPython
|
2016-01-12 15:24:23 -05:00
|
|
|
|
|
|
|
|
2016-02-28 20:44:48 -05:00
|
|
|
def EndsWithPython_Good( path ):
|
2017-03-27 16:23:39 -04:00
|
|
|
ok_( _EndsWithPython( path ),
|
|
|
|
'Path {0} does not end with a Python name.'.format( path ) )
|
2016-02-28 20:44:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
def EndsWithPython_Bad( path ):
|
2017-03-27 16:23:39 -04:00
|
|
|
ok_( not _EndsWithPython( path ),
|
|
|
|
'Path {0} does end with a Python name.'.format( path ) )
|
2016-02-28 20:44:48 -05:00
|
|
|
|
|
|
|
|
2016-01-12 16:48:48 -05:00
|
|
|
def EndsWithPython_Python2Paths_test():
|
2016-01-12 15:24:23 -05:00
|
|
|
python_paths = [
|
|
|
|
'python',
|
2016-02-28 20:44:48 -05:00
|
|
|
'python2',
|
2018-01-24 11:54:57 -05:00
|
|
|
'/usr/bin/python2.7',
|
2016-01-12 15:24:23 -05:00
|
|
|
'/home/user/.pyenv/shims/python2.7',
|
2018-01-24 11:54:57 -05:00
|
|
|
r'C:\Python27\python.exe',
|
2017-03-27 16:23:39 -04:00
|
|
|
'/Contents/MacOS/Python'
|
2016-01-12 15:24:23 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
for path in python_paths:
|
2016-02-28 20:44:48 -05:00
|
|
|
yield EndsWithPython_Good, path
|
|
|
|
|
|
|
|
|
|
|
|
def EndsWithPython_Python3Paths_test():
|
|
|
|
python_paths = [
|
|
|
|
'python3',
|
2019-03-15 21:42:55 -04:00
|
|
|
'/usr/bin/python3.5',
|
|
|
|
'/home/user/.pyenv/shims/python3.5',
|
|
|
|
r'C:\Python35\python.exe'
|
2016-02-28 20:44:48 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
for path in python_paths:
|
|
|
|
yield EndsWithPython_Good, path
|
2016-01-12 15:24:23 -05:00
|
|
|
|
|
|
|
|
2016-02-28 20:44:48 -05:00
|
|
|
def EndsWithPython_BadPaths_test():
|
2016-01-12 15:24:23 -05:00
|
|
|
not_python_paths = [
|
2016-04-25 23:24:41 -04:00
|
|
|
None,
|
|
|
|
'',
|
2016-01-12 15:24:23 -05:00
|
|
|
'/opt/local/bin/vim',
|
2016-01-12 16:48:48 -05:00
|
|
|
r'C:\Program Files\Vim\vim74\gvim.exe',
|
2016-02-28 20:44:48 -05:00
|
|
|
'/usr/bin/python2.5',
|
|
|
|
'/home/user/.pyenv/shims/python3.2',
|
2016-01-12 15:24:23 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
for path in not_python_paths:
|
2016-02-28 20:44:48 -05:00
|
|
|
yield EndsWithPython_Bad, path
|