Page MenuHomePhabricator

test_create_short_link of page_tests.TestShortLink fails
Closed, ResolvedPublic

Description

https://travis-ci.org/wikimedia/pywikibot/jobs/534636264

=================================== FAILURES ===================================
_____________________ TestShortLink.test_create_short_link _____________________
self = <tests.page_tests.TestShortLink testMethod=test_create_short_link>
    def test_create_short_link(self):
        """Test create_short_link function."""
        site = self.get_site()
        p1 = pywikibot.Page(site, 'User:Framawiki/pwb_tests/shortlink')
>       self.assertEqual(p1.create_short_link(), 'w.wiki/3Cy')
E       AssertionError: 'https://w.wiki/3Cy' != 'w.wiki/3Cy'
E       - https://w.wiki/3Cy
E       + w.wiki/3Cy
tests/page_tests.py:1188: AssertionError

Event Timeline

Xqt created this task.May 20 2019, 7:08 AM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptMay 20 2019, 7:08 AM
Xqt triaged this task as High priority.May 20 2019, 7:08 AM
Xqt added a comment.EditedMay 20 2019, 7:14 AM

Expanding this tests with subTest shows that the protocol is always given:

C:\pwb\GIT\core>pwb page_tests -v TestShortLink
tests: max_retries reduced from 15 to 1
test_create_short_link (__main__.TestShortLink)
Test create_short_link function. ...
======================================================================
FAIL: test_create_short_link (__main__.TestShortLink) (parameters='defaulted')
Test create_short_link function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\page_tests.py", line 1189, in test_create_short_link
    self.assertEqual(p1.create_short_link(), 'w.wiki/3Cy')
AssertionError: 'https://w.wiki/3Cy' != 'w.wiki/3Cy'
- https://w.wiki/3Cy
+ w.wiki/3Cy


======================================================================
FAIL: test_create_short_link (__main__.TestShortLink) (with_protocol=True)
Test create_short_link function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\page_tests.py", line 1192, in test_create_short_link
    'https://w.wiki/3Cy')
AssertionError: 'https://https://w.wiki/3Cy' != 'https://w.wiki/3Cy'
- https://https://w.wiki/3Cy
? --------
+ https://w.wiki/3Cy


======================================================================
FAIL: test_create_short_link (__main__.TestShortLink) (permalink=True)
Test create_short_link function.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\page_tests.py", line 1194, in test_create_short_link
    self.assertEqual(p1.create_short_link(permalink=True), 'w.wiki/3Cz')
AssertionError: 'https://w.wiki/3Cz' != 'w.wiki/3Cz'
- https://w.wiki/3Cz
+ w.wiki/3Cz


----------------------------------------------------------------------
Ran 1 test in 3.923s

FAILED (failures=3)

C:\pwb\GIT\core>

Expanding this tests with subTest

Do we have a general preference for using subTest rather than multiple test methods (mainly wondering for tests in a different patch).

Since T222146: Add protocol before shortened URLs, both at Meta and the Wikidata Query Engine was deployed all shortened URL returned by the API have protocols prefixed.

Change 511463 had a related patch set uploaded (by Framawiki; owner: Framawiki):
[pywikibot/core@master] [TEST] fix test_create_short_link

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

Xqt assigned this task to Framawiki.May 20 2019, 7:11 PM

Change 511463 merged by jenkins-bot:
[pywikibot/core@master] [TEST] fix test_create_short_link

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

Xqt closed this task as Resolved.May 25 2019, 10:09 AM

Thanks Framawiki!