Page MenuHomePhabricator

TestLiveCosmeticChanges.test_cleanUpLinks erroneously doesn't fail unittest
Open, HighPublic


removing unittest.expectedFailure it fails as expected and should be fixed:

C:\pwb\GIT\core> tests/cosmetic_changes_tests -v TestLiveCosmeticChanges.t
tests: max_retries reduced from 25 to 1
test_cleanUpLinks (__main__.TestLiveCosmeticChanges) ... FAIL

FAIL: test_cleanUpLinks (__main__.TestLiveCosmeticChanges)
Traceback (most recent call last):
  File ".\tests\", line 280, in test_cleanUpLinks
    self.cct.cleanUpLinks('text[[ title ]]text'))
AssertionError: u'text [[title]] text' != u'text [[title ]]text'
- text [[title]] text
?               -
+ text [[title ]]text
?             +

Ran 1 test in 1.987s

FAILED (failures=1)


Event Timeline

Broken test:

self.assertEqual('text [[title]] text',
                 self.cct.cleanUpLinks('text[[ title ]]text'))
self.assertEqual('text [[title|name]] text',
                 self.cct.cleanUpLinks('text[[ title | name ]]text'))
                 self.cct.cleanUpLinks('text[[ title |name]]text'))
self.assertEqual('text [[title|name]]text',
                 self.cct.cleanUpLinks('text[[title| name]]text'))

Live code:

if not trailingChars:
    labelLength = len(label)
    label = label.rstrip()
    hadTrailingSpaces = len(label) != labelLength

The results are instead:

  1. text [[title ]]text - the space cannot be moved outside because of if not trailingChars:
  2. text [[title|name ]]text - same bug
  3. text[[title|nametext]] - linktrail goes inside the text
  4. text [[title|nametext]] - same bug

Fix for the last two is trivial, but the first two require some brainstorming because MediaWiki parses [[title ]]text to [[title|title text]], not [[title]] text which is the intended result.

Xqt triaged this task as High priority.Dec 1 2017, 5:07 AM