Fix Python 3 support

This fixes Python 3 support for doc8.

Change-Id: Id3f3a35f2d68c4cb6eefcf7a960d7991b8f4522f
This commit is contained in:
Julien Danjou 2015-01-19 15:47:30 +01:00
parent e9cd504124
commit 4d82c269ab
4 changed files with 17 additions and 17 deletions

View File

@ -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')

View File

@ -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:

View File

@ -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

View File

@ -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]