diff --git a/.travis.yml b/.travis.yml index 2536b8d8..b236c5dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ python: - "3.6-dev" - "3.7-dev" install: - - "pip install nose coverage coveralls" + - "pip install nose coverage coveralls mock" - "pip install git+https://github.com/landscapeio/pylint-plugin-utils.git@develop" - "pip install git+https://github.com/landscapeio/pylint-common.git@develop" - "pip install git+https://github.com/landscapeio/pylint-celery.git@develop" diff --git a/tests/tools/__init__.py b/tests/tools/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tools/pylint/__init__.py b/tests/tools/pylint/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tools/pylint/test_pylint_tool.py b/tests/tools/pylint/test_pylint_tool.py new file mode 100644 index 00000000..aabf5776 --- /dev/null +++ b/tests/tools/pylint/test_pylint_tool.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +import os +import sys +from unittest import TestCase + +from prospector.config import ProspectorConfig +from prospector.finder import find_python +from prospector.tools.pylint import PylintTool + +if sys.version_info >= (3, 0): + from unittest.mock import patch +else: + from mock import patch + + +class TestPylintTool(TestCase): + def setUp(self): + with patch('sys.argv', ['']): + self.config = ProspectorConfig() + self.pylint_tool = PylintTool() + + def test_absolute_path_is_computed_correctly(self): + root = os.path.join(os.path.dirname(__file__), 'testpath', 'test.py') + root_sep_split = root.split(os.path.sep) + root_os_split = os.path.split(root) + found_files = find_python([], [root], explicit_file_mode=True) + self.pylint_tool.configure(self.config, found_files) + self.assertNotEqual(self.pylint_tool._args, + [os.path.join(*root_sep_split)]) + self.assertEqual(self.pylint_tool._args, + [os.path.join(*root_os_split)]) diff --git a/tests/tools/pylint/testpath/__init__.py b/tests/tools/pylint/testpath/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tools/pylint/testpath/testfile.py b/tests/tools/pylint/testpath/testfile.py new file mode 100644 index 00000000..e69de29b diff --git a/tox.ini b/tox.ini index 30b5feb9..8a0f3795 100644 --- a/tox.ini +++ b/tox.ini @@ -6,4 +6,5 @@ skip_missing_interpreters = true [testenv] deps = nose + py27: mock commands = nosetests tests