Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,32 @@ def parse_argv(argstring):
self.assertFalse(pep8style.ignore_code('F401'))
self.assertTrue(pep8style.ignore_code('F402'))

def test_max_line_length_reports_e501_for_long_line(self):
lines = [
'x' * (pycodestyle.MAX_LINE_LENGTH + 1) + '\n',
]

pep8style = pycodestyle.StyleGuide()
count_errors = pep8style.input_file('stdin', lines=lines)

stdout = sys.stdout.getvalue().splitlines()
self.assertEqual(count_errors, 1)
self.assertEqual(len(stdout), 1)
self.assertIn('E501 line too long', stdout[0])

def test_max_line_length_ignores_long_shebang(self):
# A very long shebang on the first line should be ignored by E501.
lines = [
'#!' + ' /usr/bin/env python ' + ('x' * 200) + '\n',
]

pep8style = pycodestyle.StyleGuide()
count_errors = pep8style.input_file('stdin', lines=lines)

stdout = sys.stdout.getvalue().splitlines()
self.assertEqual(count_errors, 0)
self.assertEqual(stdout, [])

def test_styleguide_excluded(self):
pep8style = pycodestyle.StyleGuide(paths=[E11])

Expand Down