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 triaged this task as High priority.May 20 2019, 7:08 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).

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

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

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

Thanks Framawiki!