Page MenuHomePhabricator

diff.html_comparator fails with bs4 4.0.2
Closed, DeclinedPublic

Description

bs4 4.0.2 is packages with Ubuntu precise

___________________ TestDryHTMLComparator.test_added_context ___________________
self = <tests.diff_tests.TestDryHTMLComparator testMethod=test_added_context>
    def test_added_context(self):
        """Test html_comparator's detection of added-context."""
        output = html_comparator('''
    <tr>
      <td class="diff-addedline">line 1a</td>
      <td class="diff-addedline">line \n2a</td>
    </tr>
    <tr>
      <td class="diff-addedline"><span>line 1b</span></td>
      <td class="diff-addedline">line 2b<i><span></i></span></td>
    </tr>''')
        self.assertEqual(output['added-context'],
>                        ['line 1a', 'line \n2a', 'line 1b', 'line 2b'])
E       AssertionError: Lists differ: [] != [u'line 1a', u'line \n2a', u'l...
E       
E       Second list contains 4 additional elements.
E       First extra element 0:
E       line 1a
E       
E       - []
E       + [u'line 1a', u'line \n2a', u'line 1b', u'line 2b']
tests/diff_tests.py:45: AssertionError
__________________ TestDryHTMLComparator.test_deleted_context __________________
self = <tests.diff_tests.TestDryHTMLComparator testMethod=test_deleted_context>
    def test_deleted_context(self):
        """Test html_comparator's detection of deleted-context."""
        output = html_comparator('''
    <tr>
      <td class="diff-deletedline">line 1a</td>
      <td class="diff-deletedline">line \n2a</td>
    </tr>
    <tr>
      <td class="diff-deletedline"><span>line 1b</span></td>
      <td class="diff-deletedline">line 2b<i><span></i></span></td>
    </tr>''')
        self.assertEqual(output['deleted-context'],
>                        ['line 1a', 'line \n2a', 'line 1b', 'line 2b'])
E       AssertionError: Lists differ: [] != [u'line 1a', u'line \n2a', u'l...
E       
E       Second list contains 4 additional elements.
E       First extra element 0:
E       line 1a
E       
E       - []
E       + [u'line 1a', u'line \n2a', u'line 1b', u'line 2b']
tests/diff_tests.py:59: AssertionError
________________________ TestDryHTMLComparator.test_run ________________________
self = <tests.diff_tests.TestDryHTMLComparator testMethod=test_run>
    def test_run(self):
        """Test html_comparator using examples given in mw-api docs."""
        with open(join_html_data_path('diff.html')) as filed:
            diff_html = filed.read()
        output = html_comparator(diff_html)
        self.assertEqual(
            output,
            {'added-context': ['#REDIRECT [[Template:Unsigned IP]]'],
             'deleted-context': [
                '<small><span class="autosigned">\\u2014&nbsp;Preceding '
                '[[Wikipedia:Signatures|unsigned]] comment added by '
                '[[User:{{{1}}}|{{{1}}}]] ([[User talk:{{{1}}}|talk]] \\u2022 '
                '[[Special:Contributions/{{{1}}}|contribs]]) {{{2|}}}</span>'
                '</small><!-- Template:Unsigned --><noinclude>',
>               '{{documentation}} <!-- add categories to the /doc page, '
                'not here --></noinclude>']})
E       AssertionError: {u'added-context': [], u'deleted-context': []} != {u'added-context': [u'#REDIRECT [[Template:Unsigned IP]]'], u'deleted-context':  [truncated]...
E       - {u'added-context': [], u'deleted-context': []}
E       + {u'added-context': [u'#REDIRECT [[Template:Unsigned IP]]'],
E       +  u'deleted-context': [u'<small><span class="autosigned">\\u2014&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:{{{1}}}|{{{1}}}]] ([[User talk:{{{1}}}|talk]] \\u2022 [[Special:Contributions/{{{1}}}|contribs]]) {{{2|}}}</span></small><!-- Template:Unsigned --><noinclude>',
E       +                       u'{{documentation}} <!-- add categories to the /doc page, not here --></noinclude>']}
tests/diff_tests.py:75: AssertionError
_________________ TestHTMLComparator.test_wikipedia_rev_139992 _________________
self = <tests.diff_tests.TestHTMLComparator testMethod=test_wikipedia_rev_139992>
    def test_wikipedia_rev_139992(self):
        """Test html_comparator with revision 139992 in en:wikipedia."""
        site = self.get_site()
        diff_html = site.compare(139992, 139993)
        output = html_comparator(diff_html)
>       self.assertEqual(len(output['added-context']), 1)
E       AssertionError: 0 != 1
tests/diff_tests.py:92: AssertionError

https://travis-ci.org/jayvdb/pywikibot-core/jobs/134675926

Event Timeline

Change 292338 had a related patch set uploaded (by John Vandenberg):
Add apt packages

https://gerrit.wikimedia.org/r/292338

Xqt subscribed.

Never Comes up for a Long time. currently we have bs4 4.6

Change 292338 abandoned by Xqt:
Add apt packages

Reason:
T136807 is closed. For T136808 we should use a better library

https://gerrit.wikimedia.org/r/292338