Skip to content

Commit

Permalink
Merge pull request #291 from vintasoftware/update-pycodestyle
Browse files Browse the repository at this point in the history
Update pycodestyle support
  • Loading branch information
chocoelho authored Nov 17, 2018
2 parents e3081b4 + 91342e1 commit 376e9f5
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'pyyaml',
'mccabe>=0.5.0',
'pyflakes<2.0.0,>=0.8.1',
'pycodestyle<2.4.0,>=2.0.0',
'pycodestyle<=2.4.0,>=2.0.0',
'pep8-naming>=0.3.3,<=0.4.1',
'pydocstyle>=2.0.0',
]
Expand Down
Empty file added tests/tools/pep8/__init__.py
Empty file.
41 changes: 41 additions & 0 deletions tests/tools/pep8/test_pep8_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- 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.pep8 import Pep8Tool

if sys.version_info >= (3, 0):
from unittest.mock import patch
else:
from mock import patch


class TestPep8Tool(TestCase):
def setUp(self):
with patch('sys.argv', ['']):
self.config = ProspectorConfig()
self.pep8_tool = Pep8Tool()

def test_absolute_path_is_computed_correctly(self):
root = os.path.join(os.path.dirname(__file__), 'testpath', 'testfile.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.pep8_tool.configure(self.config, found_files)
self.assertNotEqual(self.pep8_tool.checker.paths,
[os.path.join(*root_sep_split)])
self.assertEqual(self.pep8_tool.checker.paths,
[os.path.join(*root_os_split)])

def test_pycodestyle_space_and_tabs(self):
root = os.path.join(os.path.dirname(__file__), 'testpath', 'test_space_tab.py')
found_files = find_python([], [root], explicit_file_mode=True)
self.pep8_tool.configure(self.config, found_files)
messages = self.pep8_tool.run([])
self.assertTrue(any(message.code == 'E101' for message in messages))
self.assertTrue(any(message.code == 'E111' for message in messages))
self.assertTrue(any(message.code == 'W191' for message in messages))
self.assertTrue(all(message.source == 'pep8' for message in messages))
Empty file.
5 changes: 5 additions & 0 deletions tests/tools/pep8/testpath/test_space_tab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
for a in 'abc':
print(a) # indented with 8 spaces
for b in 'xyz':
print(b) # indented with 1 tab
Empty file.
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py33,py34,py35,py36,py37
envlist = py27,py34,py35,py36,py37

skip_missing_interpreters = true

Expand Down

0 comments on commit 376e9f5

Please sign in to comment.