diff --git a/doc8/checks.py b/doc8/checks.py index 4637e9e..648e499 100644 --- a/doc8/checks.py +++ b/doc8/checks.py @@ -80,7 +80,7 @@ class CheckNewlineEndOfFile(ContentCheck): super(CheckNewlineEndOfFile, self).__init__(cfg) def report_iter(self, parsed_file): - if parsed_file.lines and not parsed_file.lines[-1].endswith('\n'): + if parsed_file.lines and not parsed_file.lines[-1].endswith(b'\n'): yield (len(parsed_file.lines), 'D005', 'No newline at end of file') diff --git a/doc8/tests/test_checks.py b/doc8/tests/test_checks.py index 1e0171b..2d040c9 100644 --- a/doc8/tests/test_checks.py +++ b/doc8/tests/test_checks.py @@ -60,7 +60,7 @@ class TestCarriageReturn(testtools.TestCase): class TestLineLength(testtools.TestCase): def test_over_length(self): - content = """ + content = b""" === aaa === @@ -70,9 +70,9 @@ test ---- """ - content += "\n\n" - content += ("a" * 60) + " " + ("b" * 60) - content += "\n" + content += b"\n\n" + content += (b"a" * 60) + b" " + (b"b" * 60) + content += b"\n" conf = { 'max_line_length': 79, 'allow_long_titles': True, @@ -96,8 +96,8 @@ test } with tempfile.NamedTemporaryFile(suffix='.rst') as fh: fh.write(b'known exploit in the wild, for example' - ' \xe2\x80\x93 the time' - ' between advance notification') + b' \xe2\x80\x93 the time' + b' between advance notification') fh.flush() parsed_file = parser.ParsedFile(fh.name, encoding='utf-8') @@ -106,7 +106,7 @@ test self.assertEqual(0, len(errors)) def test_unsplittable_length(self): - content = """ + content = b""" === aaa === @@ -116,9 +116,9 @@ test ---- """ - content += "\n\n" - content += "a" * 100 - content += "\n" + content += b"\n\n" + content += b"a" * 100 + content += b"\n" conf = { 'max_line_length': 79, 'allow_long_titles': True, @@ -140,10 +140,10 @@ test class TestNewlineEndOfFile(testtools.TestCase): def test_newline(self): - tests = [(1, "testing"), - (1, "testing\ntesting"), - (0, "testing\n"), - (0, "testing\ntesting\n")] + tests = [(1, b"testing"), + (1, b"testing\ntesting"), + (0, b"testing\n"), + (0, b"testing\ntesting\n")] for expected_errors, line in tests: with tempfile.NamedTemporaryFile() as fh: diff --git a/test-requirements.txt b/test-requirements.txt index 5bdff22..0b9685f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,6 +6,5 @@ doc8 hacking>=0.9.2,<0.10 nose oslosphinx -pylint==0.25.2 sphinx>=1.1.2,!=1.2.0,<1.3 testtools diff --git a/tox.ini b/tox.ini index a155b23..df5be36 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] minversion = 1.6 skipsdist = True -envlist = py26,py27,pep8 +envlist = py26,py27,py34,pep8 [testenv] setenv = VIRTUAL_ENV={envdir} @@ -15,6 +15,7 @@ commands = nosetests {posargs} commands = flake8 {posargs} [testenv:pylint] +requirements = pylint==0.25.2 commands = pylint doc8 [tox:jenkins]