flake8 fixes

This commit is contained in:
Andrea Corbellini 2018-02-08 18:39:29 +01:00
commit fc7af9e1c3
2 changed files with 16 additions and 10 deletions

View file

@ -218,12 +218,18 @@ class TestUtils(LoggedTestCase):
"∫dx " * 20 + '') "∫dx " * 20 + '')
# Words with invalid or broken HTML references. # Words with invalid or broken HTML references.
self.assertEqual(utils.truncate_html_words('&invalid;', 20), '&invalid;') self.assertEqual(
self.assertEqual(utils.truncate_html_words('�', 20), '�') utils.truncate_html_words('&invalid;', 20), '&invalid;')
self.assertEqual(utils.truncate_html_words('�', 20), '�') self.assertEqual(
self.assertEqual(utils.truncate_html_words('&mdash', 20), '&mdash') utils.truncate_html_words('�', 20), '�')
self.assertEqual(utils.truncate_html_words('&#1234', 20), '&#1234') self.assertEqual(
self.assertEqual(utils.truncate_html_words('&#xabc', 20), '&#xabc') utils.truncate_html_words('�', 20), '�')
self.assertEqual(
utils.truncate_html_words('&mdash', 20), '&mdash')
self.assertEqual(
utils.truncate_html_words('&#1234', 20), '&#1234')
self.assertEqual(
utils.truncate_html_words('&#xabc', 20), '&#xabc')
def test_process_translations(self): def test_process_translations(self):
fr_articles = [] fr_articles = []

View file

@ -552,15 +552,15 @@ class _HTMLWordTruncator(HTMLParser):
def _handle_ref(self, name, char): def _handle_ref(self, name, char):
""" """
Called by handle_entityref() or handle_charref() when a ref like Called by handle_entityref() or handle_charref() when a ref like
`—`, `—`, or `&#x2014` is found. `—`, `—`, or `&#x2014` is found.
The arguments for this method are: The arguments for this method are:
- `name`: the HTML entity name (such as `mdash` or `#8212` or `#x2014`) - `name`: the HTML entity name (such as `mdash` or `#8212` or `#x2014`)
- `char`: the Unicode representation of the ref (such as ``) - `char`: the Unicode representation of the ref (such as ``)
This method checks whether the entity is considered to be part of a This method checks whether the entity is considered to be part of a
word or not and, if not, signals the end of a word. word or not and, if not, signals the end of a word.
""" """
# Compute the index of the character right after the ref. # Compute the index of the character right after the ref.