Browse Source

Fix Python 3 support

This fixes Python 3 support for doc8.

Change-Id: Id3f3a35f2d68c4cb6eefcf7a960d7991b8f4522f
Julien Danjou 4 years ago
parent
commit
4d82c269ab
4 changed files with 17 additions and 17 deletions
  1. 1
    1
      doc8/checks.py
  2. 14
    14
      doc8/tests/test_checks.py
  3. 0
    1
      test-requirements.txt
  4. 2
    1
      tox.ini

+ 1
- 1
doc8/checks.py View File

@@ -80,7 +80,7 @@ class CheckNewlineEndOfFile(ContentCheck):
80 80
         super(CheckNewlineEndOfFile, self).__init__(cfg)
81 81
 
82 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 84
             yield (len(parsed_file.lines), 'D005', 'No newline at end of file')
85 85
 
86 86
 

+ 14
- 14
doc8/tests/test_checks.py View File

@@ -60,7 +60,7 @@ class TestCarriageReturn(testtools.TestCase):
60 60
 
61 61
 class TestLineLength(testtools.TestCase):
62 62
     def test_over_length(self):
63
-        content = """
63
+        content = b"""
64 64
 ===
65 65
 aaa
66 66
 ===
@@ -70,9 +70,9 @@ test
70 70
 ----
71 71
 
72 72
 """
73
-        content += "\n\n"
74
-        content += ("a" * 60) + " " + ("b" * 60)
75
-        content += "\n"
73
+        content += b"\n\n"
74
+        content += (b"a" * 60) + b" " + (b"b" * 60)
75
+        content += b"\n"
76 76
         conf = {
77 77
             'max_line_length': 79,
78 78
             'allow_long_titles': True,
@@ -96,8 +96,8 @@ test
96 96
         }
97 97
         with tempfile.NamedTemporaryFile(suffix='.rst') as fh:
98 98
             fh.write(b'known exploit in the wild, for example'
99
-                     ' \xe2\x80\x93 the time'
100
-                     ' between advance notification')
99
+                     b' \xe2\x80\x93 the time'
100
+                     b' between advance notification')
101 101
             fh.flush()
102 102
 
103 103
             parsed_file = parser.ParsedFile(fh.name, encoding='utf-8')
@@ -106,7 +106,7 @@ test
106 106
             self.assertEqual(0, len(errors))
107 107
 
108 108
     def test_unsplittable_length(self):
109
-        content = """
109
+        content = b"""
110 110
 ===
111 111
 aaa
112 112
 ===
@@ -116,9 +116,9 @@ test
116 116
 ----
117 117
 
118 118
 """
119
-        content += "\n\n"
120
-        content += "a" * 100
121
-        content += "\n"
119
+        content += b"\n\n"
120
+        content += b"a" * 100
121
+        content += b"\n"
122 122
         conf = {
123 123
             'max_line_length': 79,
124 124
             'allow_long_titles': True,
@@ -140,10 +140,10 @@ test
140 140
 
141 141
 class TestNewlineEndOfFile(testtools.TestCase):
142 142
     def test_newline(self):
143
-        tests = [(1, "testing"),
144
-                 (1, "testing\ntesting"),
145
-                 (0, "testing\n"),
146
-                 (0, "testing\ntesting\n")]
143
+        tests = [(1, b"testing"),
144
+                 (1, b"testing\ntesting"),
145
+                 (0, b"testing\n"),
146
+                 (0, b"testing\ntesting\n")]
147 147
 
148 148
         for expected_errors, line in tests:
149 149
             with tempfile.NamedTemporaryFile() as fh:

+ 0
- 1
test-requirements.txt View File

@@ -6,6 +6,5 @@ doc8
6 6
 hacking>=0.9.2,<0.10
7 7
 nose
8 8
 oslosphinx
9
-pylint==0.25.2
10 9
 sphinx>=1.1.2,!=1.2.0,<1.3
11 10
 testtools

+ 2
- 1
tox.ini View File

@@ -1,7 +1,7 @@
1 1
 [tox]
2 2
 minversion = 1.6
3 3
 skipsdist = True
4
-envlist = py26,py27,pep8
4
+envlist = py26,py27,py34,pep8
5 5
 
6 6
 [testenv]
7 7
 setenv = VIRTUAL_ENV={envdir}
@@ -15,6 +15,7 @@ commands = nosetests {posargs}
15 15
 commands = flake8 {posargs}
16 16
 
17 17
 [testenv:pylint]
18
+requirements = pylint==0.25.2
18 19
 commands = pylint doc8
19 20
 
20 21
 [tox:jenkins]

Loading…
Cancel
Save