Fix Python 3 support
This fixes Python 3 support for doc8. Change-Id: Id3f3a35f2d68c4cb6eefcf7a960d7991b8f4522f
This commit is contained in:
		@@ -80,7 +80,7 @@ class CheckNewlineEndOfFile(ContentCheck):
 | 
				
			|||||||
        super(CheckNewlineEndOfFile, self).__init__(cfg)
 | 
					        super(CheckNewlineEndOfFile, self).__init__(cfg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def report_iter(self, parsed_file):
 | 
					    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')
 | 
					            yield (len(parsed_file.lines), 'D005', 'No newline at end of file')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,7 +60,7 @@ class TestCarriageReturn(testtools.TestCase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class TestLineLength(testtools.TestCase):
 | 
					class TestLineLength(testtools.TestCase):
 | 
				
			||||||
    def test_over_length(self):
 | 
					    def test_over_length(self):
 | 
				
			||||||
        content = """
 | 
					        content = b"""
 | 
				
			||||||
===
 | 
					===
 | 
				
			||||||
aaa
 | 
					aaa
 | 
				
			||||||
===
 | 
					===
 | 
				
			||||||
@@ -70,9 +70,9 @@ test
 | 
				
			|||||||
----
 | 
					----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
        content += "\n\n"
 | 
					        content += b"\n\n"
 | 
				
			||||||
        content += ("a" * 60) + " " + ("b" * 60)
 | 
					        content += (b"a" * 60) + b" " + (b"b" * 60)
 | 
				
			||||||
        content += "\n"
 | 
					        content += b"\n"
 | 
				
			||||||
        conf = {
 | 
					        conf = {
 | 
				
			||||||
            'max_line_length': 79,
 | 
					            'max_line_length': 79,
 | 
				
			||||||
            'allow_long_titles': True,
 | 
					            'allow_long_titles': True,
 | 
				
			||||||
@@ -96,8 +96,8 @@ test
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        with tempfile.NamedTemporaryFile(suffix='.rst') as fh:
 | 
					        with tempfile.NamedTemporaryFile(suffix='.rst') as fh:
 | 
				
			||||||
            fh.write(b'known exploit in the wild, for example'
 | 
					            fh.write(b'known exploit in the wild, for example'
 | 
				
			||||||
                     ' \xe2\x80\x93 the time'
 | 
					                     b' \xe2\x80\x93 the time'
 | 
				
			||||||
                     ' between advance notification')
 | 
					                     b' between advance notification')
 | 
				
			||||||
            fh.flush()
 | 
					            fh.flush()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            parsed_file = parser.ParsedFile(fh.name, encoding='utf-8')
 | 
					            parsed_file = parser.ParsedFile(fh.name, encoding='utf-8')
 | 
				
			||||||
@@ -106,7 +106,7 @@ test
 | 
				
			|||||||
            self.assertEqual(0, len(errors))
 | 
					            self.assertEqual(0, len(errors))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_unsplittable_length(self):
 | 
					    def test_unsplittable_length(self):
 | 
				
			||||||
        content = """
 | 
					        content = b"""
 | 
				
			||||||
===
 | 
					===
 | 
				
			||||||
aaa
 | 
					aaa
 | 
				
			||||||
===
 | 
					===
 | 
				
			||||||
@@ -116,9 +116,9 @@ test
 | 
				
			|||||||
----
 | 
					----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
        content += "\n\n"
 | 
					        content += b"\n\n"
 | 
				
			||||||
        content += "a" * 100
 | 
					        content += b"a" * 100
 | 
				
			||||||
        content += "\n"
 | 
					        content += b"\n"
 | 
				
			||||||
        conf = {
 | 
					        conf = {
 | 
				
			||||||
            'max_line_length': 79,
 | 
					            'max_line_length': 79,
 | 
				
			||||||
            'allow_long_titles': True,
 | 
					            'allow_long_titles': True,
 | 
				
			||||||
@@ -140,10 +140,10 @@ test
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class TestNewlineEndOfFile(testtools.TestCase):
 | 
					class TestNewlineEndOfFile(testtools.TestCase):
 | 
				
			||||||
    def test_newline(self):
 | 
					    def test_newline(self):
 | 
				
			||||||
        tests = [(1, "testing"),
 | 
					        tests = [(1, b"testing"),
 | 
				
			||||||
                 (1, "testing\ntesting"),
 | 
					                 (1, b"testing\ntesting"),
 | 
				
			||||||
                 (0, "testing\n"),
 | 
					                 (0, b"testing\n"),
 | 
				
			||||||
                 (0, "testing\ntesting\n")]
 | 
					                 (0, b"testing\ntesting\n")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for expected_errors, line in tests:
 | 
					        for expected_errors, line in tests:
 | 
				
			||||||
            with tempfile.NamedTemporaryFile() as fh:
 | 
					            with tempfile.NamedTemporaryFile() as fh:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,5 @@ doc8
 | 
				
			|||||||
hacking>=0.9.2,<0.10
 | 
					hacking>=0.9.2,<0.10
 | 
				
			||||||
nose
 | 
					nose
 | 
				
			||||||
oslosphinx
 | 
					oslosphinx
 | 
				
			||||||
pylint==0.25.2
 | 
					 | 
				
			||||||
sphinx>=1.1.2,!=1.2.0,<1.3
 | 
					sphinx>=1.1.2,!=1.2.0,<1.3
 | 
				
			||||||
testtools
 | 
					testtools
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								tox.ini
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tox.ini
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
				
			|||||||
[tox]
 | 
					[tox]
 | 
				
			||||||
minversion = 1.6
 | 
					minversion = 1.6
 | 
				
			||||||
skipsdist = True
 | 
					skipsdist = True
 | 
				
			||||||
envlist = py26,py27,pep8
 | 
					envlist = py26,py27,py34,pep8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[testenv]
 | 
					[testenv]
 | 
				
			||||||
setenv = VIRTUAL_ENV={envdir}
 | 
					setenv = VIRTUAL_ENV={envdir}
 | 
				
			||||||
@@ -15,6 +15,7 @@ commands = nosetests {posargs}
 | 
				
			|||||||
commands = flake8 {posargs}
 | 
					commands = flake8 {posargs}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[testenv:pylint]
 | 
					[testenv:pylint]
 | 
				
			||||||
 | 
					requirements = pylint==0.25.2
 | 
				
			||||||
commands = pylint doc8
 | 
					commands = pylint doc8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[tox:jenkins]
 | 
					[tox:jenkins]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user