@@ -342,5 +342,50 @@ def test_check_nullbytes(self):
342342 self .assertFalse (sys .stderr )
343343 self .assertEqual (count_errors , 1 )
344344
345+ def test_styleguide_unmatched_triple_quotes (self ):
346+ pep8 .register_check (DummyChecker , ['Z701' ])
347+ lines = [
348+ 'def foo():\n ' ,
349+ ' """test docstring""\' \n ' ,
350+ ]
351+
352+ pep8style = pep8 .StyleGuide ()
353+ count_errors = pep8style .input_file ('stdin' , lines = lines )
354+ stdout = sys .stdout .getvalue ()
355+ self .assertEqual (count_errors , 2 )
356+
357+ expected = 'stdin:2:5: E901 TokenError: EOF in multi-line string'
358+ self .assertTrue (expected in stdout )
359+
360+ expected = (
361+ 'stdin:2:26: '
362+ 'E901 SyntaxError: EOF while scanning triple-quoted string literal'
363+ )
364+ self .assertTrue (expected in stdout )
365+
366+ def test_styleguide_continuation_line_outdented (self ):
367+ pep8 .register_check (DummyChecker , ['Z701' ])
368+ lines = [
369+ 'def foo():\n ' ,
370+ ' pass\n ' ,
371+ '\n ' ,
372+ '\\ \n ' ,
373+ '\n ' ,
374+ 'def bar():\n ' ,
375+ ' pass\n ' ,
376+ ]
377+
378+ pep8style = pep8 .StyleGuide ()
379+ count_errors = pep8style .input_file ('stdin' , lines = lines )
380+ self .assertEqual (count_errors , 2 )
381+ stdout = sys .stdout .getvalue ()
382+ expected = (
383+ 'stdin:6:1: '
384+ 'E122 continuation line missing indentation or outdented'
385+ )
386+ self .assertTrue (expected in stdout )
387+ expected = 'stdin:6:1: E302 expected 2 blank lines, found 1'
388+ self .assertTrue (expected in stdout )
389+
345390 # TODO: runner
346391 # TODO: input_file
0 commit comments