paths_test.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. import pytest
  20. from hamcrest import assert_that
  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. @pytest.mark.parametrize( 'path', [
  29. 'python3',
  30. '/usr/bin/python3.6',
  31. '/home/user/.pyenv/shims/python3.6',
  32. r'C:\Python36\python.exe'
  33. ] )
  34. def EndsWithPython_Python3Paths_test( path ):
  35. EndsWithPython_Good( path )
  36. @pytest.mark.parametrize( 'path', [
  37. None,
  38. '',
  39. '/opt/local/bin/vim',
  40. r'C:\Program Files\Vim\vim74\gvim.exe',
  41. '/usr/bin/python2.7',
  42. '/home/user/.pyenv/shims/python3.2',
  43. ] )
  44. def EndsWithPython_BadPaths_test( path ):
  45. EndsWithPython_Bad( path )