Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 9b118d5

Browse files
author
Vladimir Keleshev
committed
Merge pull request #65 from ziadsawalha/more-tests
Add tests and fixed bug where new 209 was failing
2 parents 153b0fe + e091c94 commit 9b118d5

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

pep257.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,7 @@ def check_newline_after_last_paragraph(self, definition, docstring):
609609
if docstring:
610610
lines = [l for l in eval(docstring).split('\n') if not is_blank(l)]
611611
if len(lines) > 1:
612-
lines = eval(docstring).split('\n')
613-
blanks = len(list(takewhile(is_blank, reversed(lines))))
614-
if blanks < 2:
612+
if docstring.split("\n")[-1].strip() not in ['"""', "'''"]:
615613
return Error('D209: Put multi-line docstring closing '
616614
'quotes on separate line')
617615

test.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""Docstring."""
21
# encoding: utf-8
2+
# No docstring, so we can test D100
33
import sys
44

55

@@ -201,9 +201,26 @@ def foobar():
201201
"""Signature: foobar()."""
202202

203203

204+
def new_209():
205+
"""First line.
206+
207+
More lines.
208+
"""
209+
pass
210+
211+
212+
def old_209():
213+
"""One liner.
214+
215+
Multi-line comments. OK to have extra blank line
216+
217+
"""
218+
219+
204220
def run():
205221
"""Run the functions above and check errors agains expected errors."""
206222
import pep257
223+
expect(__file__, 'D100: Docstring missing')
207224
results = list(pep257.check([__file__]))
208225
assert set(map(type, results)) == set([pep257.Error]), results
209226
results = set([(e.definition.name, e.message) for e in results])

0 commit comments

Comments
 (0)