Skip to content

Commit

Permalink
Compatibility with Tidy 5.5.19 and newer
Browse files Browse the repository at this point in the history
It changed how non existing files are handled.

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=910974
  • Loading branch information
nijel committed Oct 15, 2018
1 parent eeb7c0f commit 858cd3c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions tidy/lib.py
Expand Up @@ -102,13 +102,18 @@ class ReportItem(object):
"""
Error report item as returned by tidy.
:attribute severity: W, E or C indicating severity
:attribute severity: D, W, E or C indicating severity
:attribute line: Line where error was fired (can be None)
:attribute col: Column where error was fired (can be None)
:attribute message: Error message itsef
:attribute err: Whole error message as returned by tidy
"""
severities = {'W': 'Warning', 'E': 'Error', 'C': 'Config'}
severities = {
'W': 'Warning',
'E': 'Error',
'C': 'Config',
'D': 'Document',
}

def __init__(self, err):
# TODO - parse emacs mode
Expand Down
11 changes: 8 additions & 3 deletions tidy/test_tidy.py
Expand Up @@ -52,10 +52,15 @@ def test_error_lines(self):

def test_nonexisting(self):
doc = tidy.parse(os.path.join(DATA_STORAGE, 'missing.html'))
self.assertEquals(str(doc), '')
self.assertEquals(str(doc).strip(), '')
self.assertIn('missing.html', doc.errors[0].message)
self.assertEquals(doc.errors[0].severity, 'E')
self.assertTrue(str(doc.errors[0]).startswith('Error'))
if doc.errors[0].severity == 'E':
self.assertEquals(doc.errors[0].severity, 'E')
self.assertTrue(str(doc.errors[0]).startswith('Error'))
else:
# Tidy 5.5.19 and newer
self.assertEquals(doc.errors[0].severity, 'D')
self.assertTrue(str(doc.errors[0]).startswith('Document'))

def test_options(self):
doc1 = tidy.parseString(
Expand Down

0 comments on commit 858cd3c

Please sign in to comment.