summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2015-01-19 15:47:30 +0100
committerJulien Danjou <julien@danjou.info>2015-01-27 14:33:56 +0100
commit4d82c269ab46f0c5370c1f00be06e0c406164e85 (patch)
tree890f6feb588c0bc573300f1866e772d04484951b
parente9cd504124b4ad5c4f1345efefe10a2ef6217663 (diff)
Fix Python 3 support
This fixes Python 3 support for doc8. Change-Id: Id3f3a35f2d68c4cb6eefcf7a960d7991b8f4522f
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Christian Berendt <berendt@b1-systems.de> Workflow+1: Christian Berendt <berendt@b1-systems.de> Submitted-by: Jenkins Submitted-at: Tue, 27 Jan 2015 13:54:33 +0000 Reviewed-on: https://review.openstack.org/148274 Project: stackforge/doc8 Branch: refs/heads/master
-rw-r--r--doc8/checks.py2
-rw-r--r--doc8/tests/test_checks.py28
-rw-r--r--test-requirements.txt1
-rw-r--r--tox.ini3
4 files changed, 17 insertions, 17 deletions
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):
80 super(CheckNewlineEndOfFile, self).__init__(cfg) 80 super(CheckNewlineEndOfFile, self).__init__(cfg)
81 81
82 def report_iter(self, parsed_file): 82 def report_iter(self, parsed_file):
83 if parsed_file.lines and not parsed_file.lines[-1].endswith('\n'): 83 if parsed_file.lines and not parsed_file.lines[-1].endswith(b'\n'):
84 yield (len(parsed_file.lines), 'D005', 'No newline at end of file') 84 yield (len(parsed_file.lines), 'D005', 'No newline at end of file')
85 85
86 86
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):
60 60
61class TestLineLength(testtools.TestCase): 61class TestLineLength(testtools.TestCase):
62 def test_over_length(self): 62 def test_over_length(self):
63 content = """ 63 content = b"""
64=== 64===
65aaa 65aaa
66=== 66===
@@ -70,9 +70,9 @@ test
70---- 70----
71 71
72""" 72"""
73 content += "\n\n" 73 content += b"\n\n"
74 content += ("a" * 60) + " " + ("b" * 60) 74 content += (b"a" * 60) + b" " + (b"b" * 60)
75 content += "\n" 75 content += b"\n"
76 conf = { 76 conf = {
77 'max_line_length': 79, 77 'max_line_length': 79,
78 'allow_long_titles': True, 78 'allow_long_titles': True,
@@ -96,8 +96,8 @@ test
96 } 96 }
97 with tempfile.NamedTemporaryFile(suffix='.rst') as fh: 97 with tempfile.NamedTemporaryFile(suffix='.rst') as fh:
98 fh.write(b'known exploit in the wild, for example' 98 fh.write(b'known exploit in the wild, for example'
99 ' \xe2\x80\x93 the time' 99 b' \xe2\x80\x93 the time'
100 ' between advance notification') 100 b' between advance notification')
101 fh.flush() 101 fh.flush()
102 102
103 parsed_file = parser.ParsedFile(fh.name, encoding='utf-8') 103 parsed_file = parser.ParsedFile(fh.name, encoding='utf-8')
@@ -106,7 +106,7 @@ test
106 self.assertEqual(0, len(errors)) 106 self.assertEqual(0, len(errors))
107 107
108 def test_unsplittable_length(self): 108 def test_unsplittable_length(self):
109 content = """ 109 content = b"""
110=== 110===
111aaa 111aaa
112=== 112===
@@ -116,9 +116,9 @@ test
116---- 116----
117 117
118""" 118"""
119 content += "\n\n" 119 content += b"\n\n"
120 content += "a" * 100 120 content += b"a" * 100
121 content += "\n" 121 content += b"\n"
122 conf = { 122 conf = {
123 'max_line_length': 79, 123 'max_line_length': 79,
124 'allow_long_titles': True, 124 'allow_long_titles': True,
@@ -140,10 +140,10 @@ test
140 140
141class TestNewlineEndOfFile(testtools.TestCase): 141class TestNewlineEndOfFile(testtools.TestCase):
142 def test_newline(self): 142 def test_newline(self):
143 tests = [(1, "testing"), 143 tests = [(1, b"testing"),
144 (1, "testing\ntesting"), 144 (1, b"testing\ntesting"),
145 (0, "testing\n"), 145 (0, b"testing\n"),
146 (0, "testing\ntesting\n")] 146 (0, b"testing\ntesting\n")]
147 147
148 for expected_errors, line in tests: 148 for expected_errors, line in tests:
149 with tempfile.NamedTemporaryFile() as fh: 149 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
6hacking>=0.9.2,<0.10 6hacking>=0.9.2,<0.10
7nose 7nose
8oslosphinx 8oslosphinx
9pylint==0.25.2
10sphinx>=1.1.2,!=1.2.0,<1.3 9sphinx>=1.1.2,!=1.2.0,<1.3
11testtools 10testtools
diff --git a/tox.ini b/tox.ini
index a155b23..df5be36 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
1[tox] 1[tox]
2minversion = 1.6 2minversion = 1.6
3skipsdist = True 3skipsdist = True
4envlist = py26,py27,pep8 4envlist = py26,py27,py34,pep8
5 5
6[testenv] 6[testenv]
7setenv = VIRTUAL_ENV={envdir} 7setenv = VIRTUAL_ENV={envdir}
@@ -15,6 +15,7 @@ commands = nosetests {posargs}
15commands = flake8 {posargs} 15commands = flake8 {posargs}
16 16
17[testenv:pylint] 17[testenv:pylint]
18requirements = pylint==0.25.2
18commands = pylint doc8 19commands = pylint doc8
19 20
20[tox:jenkins] 21[tox:jenkins]