Skip to content

Commit

Permalink
Add test for path split and regression for old path behavior
Browse files Browse the repository at this point in the history
Mock argv before calling ProspectorConfig in tests
  • Loading branch information
chocoelho committed May 18, 2018
1 parent 6522182 commit e66b1a2
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Empty file added tests/tools/__init__.py
Empty file.
Empty file added tests/tools/pylint/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions tests/tools/pylint/test_pylint_tool.py
Original file line number Diff line number Diff line change
@@ -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)])
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ skip_missing_interpreters = true
[testenv]
deps =
nose
py27: mock
commands = nosetests tests

0 comments on commit e66b1a2

Please sign in to comment.