paths_test.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright (C) 2016-2017 YouCompleteMe contributors
  2. #
  3. # This file is part of YouCompleteMe.
  4. #
  5. # YouCompleteMe is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # YouCompleteMe is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
  17. from ycm.tests.test_utils import MockVimModule
  18. MockVimModule()
  19. from hamcrest import assert_that
  20. from unittest import TestCase
  21. from ycm.paths import _EndsWithPython
  22. def EndsWithPython_Good( path ):
  23. assert_that( _EndsWithPython( path ),
  24. f'Path { path } does not end with a Python name.' )
  25. def EndsWithPython_Bad( path ):
  26. assert_that( not _EndsWithPython( path ),
  27. f'Path { path } does end with a Python name.' )
  28. class PathTest( TestCase ):
  29. def test_EndsWithPython_Python3Paths( self ):
  30. for path in [
  31. 'python3',
  32. '/usr/bin/python3.6',
  33. '/home/user/.pyenv/shims/python3.6',
  34. r'C:\Python36\python.exe'
  35. ]:
  36. with self.subTest( path = path ):
  37. EndsWithPython_Good( path )
  38. def test_EndsWithPython_BadPaths( self ):
  39. for path in [
  40. None,
  41. '',
  42. '/opt/local/bin/vim',
  43. r'C:\Program Files\Vim\vim74\gvim.exe',
  44. '/usr/bin/python2.7',
  45. '/home/user/.pyenv/shims/python3.2',
  46. ]:
  47. with self.subTest( path = path ):
  48. EndsWithPython_Bad( path )