Edgewall Software

Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#12850 closed defect (fixed)

Test failure with trac.wiki.tests.functional.TestWikiDelete — at Version 3

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: normal Milestone: 1.3.2
Component: wiki system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fix wrong msgid_plural in wiki_delete.html.

API Changes:
Internal Changes:

Description

Failure seen on AppVeyor and Travis CI.

======================================================================
FAIL: runTest (trac.wiki.tests.functional.TestWikiDelete)
Delete a wiki page.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/edgewall/trac/trac/wiki/tests/functional.py", line 76, in runTest
    r'version=2">all 2 versions</a>\s+of the page' % name)
  File "/home/travis/build/edgewall/trac/trac/tests/functional/better_twill.py", line 224, in better_find
    (to_unicode(e), filename))
TwillAssertionError: no match to 'Removing\s+<a href="/wiki/BagpipeTongue\?action=history&amp;version=2">all 2 versions</a>\s+of the page' at file:///home/travis/build/edgewall/trac/testenv/trac/log/TestWikiDelete.html
----------------------------------------------------------------------
Ran 222 tests in 677.196s
FAILED (failures=1)
make: *** [functional-test] Error 1

Change History (3)

comment:1 by Jun Omae, 7 years ago

ngettext() is used in wiki_delete.html like this:

 73           # set num_versions
 74           <a href="${history_href}">${
 75             ngettext("%(num)d version", "%(num)d versions", num=num_versions)
 76           }</a>
 77           # endset
...
131           #   set num_versions
132           <a href="${history_href}">${
133             ngettext("%(num)d version", "all %(num)d versions", num=num_versions)
134             }</a>
135           #   endset

extract_messages command extracts "%(num)d version" and "%(num)d versions" from the above but "all %(num)d versions" is not extracted.

#: trac/wiki/templates/wiki_delete.html:75
#: trac/wiki/templates/wiki_delete.html:133
#, python-format
msgid "%(num)d version"
msgid_plural "%(num)d versions"
msgstr[0] ""
msgstr[1] ""

comment:2 by Jun Omae, 7 years ago

Owner: set to Jun Omae
Status: newassigned

extract_messages command's behavior is right. msgid_plural is used only when messages catalog is not found for active language. msgid is used as a key and must be unique without msgid_plural. Therefore, usage of ngettext in wiki_delete.html is wrong.

  • trac/wiki/templates/wiki_delete.html

    diff --git a/trac/wiki/templates/wiki_delete.html b/trac/wiki/templates/wiki_delete.html
    index d9b68553c..172e87830 100644
    a b  
    130130          # else:
    131131          #   set num_versions
    132132          <a href="${history_href}">${
    133             ngettext("%(num)d version", "all %(num)d versions", num=num_versions)
     133            ngettext("%(num)d version", "%(num)d versions", num=num_versions)
    134134            }</a>
    135135          #   endset
    136136          #   trans num_versions, created = first_modified, modified = last_modified
    137137
    138           Removing ${num_versions} of the page, which was created
     138          Removing all ${num_versions} of the page, which was created
    139139          ${created} and last modified ${modified}.
    140140
    141141          #   endtrans
  • trac/wiki/tests/functional.py

    diff --git a/trac/wiki/tests/functional.py b/trac/wiki/tests/functional.py
    index 292099581..a46c5d769 100755
    a b class TestWikiDelete(FunctionalTwillTestCaseSetup):  
    7272        tc.formvalue('delete', 'action', 'delete')
    7373        tc.submit('delete_page')
    7474        tc.find("Are you sure you want to completely delete this page?")
    75         tc.find(r'Removing\s+<a href="/wiki/%s\?action=history&amp;'
    76                 r'version=2">all 2 versions</a>\s+of the page' % name)
     75        tc.find(r'Removing all\s+<a href="/wiki/%s\?action=history&amp;'
     76                r'version=2">2 versions</a>\s+of the page' % name)
    7777        tc.notfind("The following attachments will also be deleted:")
    7878        tc.submit('delete', 'delete-confirm')
    7979        tc.find("The page %s has been deleted." % name)
Last edited 7 years ago by Jun Omae (previous) (diff)

comment:3 by Jun Omae, 7 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [16076].

Note: See TracTickets for help on using tickets.