Merge lp:~sinzui/launchpad/6-plural-forms into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 13068 | ||||
Proposed branch: | lp:~sinzui/launchpad/6-plural-forms | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
121 lines (+51/-14) 2 files modified
lib/lp/translations/browser/tests/test_translationmessage_view.py (+41/-3) lib/lp/translations/browser/translationmessage.py (+10/-11) |
||||
To merge this branch: | bzr merge lp:~sinzui/launchpad/6-plural-forms | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Steve Kowalik (community) | code | Approve | |
Review via email: mp+61322@code.launchpad.net |
Description of the change
Do not raise an AssertionError when the MAX_PLURAL_FORMS is honoured.
Launchpad bug: https:/
Pre-
OOPS-1853D2494 shows that a user submitted 6 translations, each field indexed
from 0 to 5, but an assert error was raised stating that more than 6
translations were submitted.
JTV wrote:
The check does something like…
for pluralform in xrange(6):
# …
if pluralform not in translations_
break
# …
else:
raise AssertionError(
That goes wrong if you submit exactly 6 plural forms. The loop then never hits
a plural-form number that didn't have a translation submitted, and drops into
the "else" part.
The loop requires that 'break' be called during when an empty translation
is found while iterating over exactly 6 items. It is impossible to submit
6 translations! The assertion exists to ensure that the generated form
fields match the configured number of possible translations.
-------
RULES
* Since the assertion is predicated on the existence of a 7th field with
the index of 6, a guard can check for the existence of the field before
there is an attempt to store the submitted data.
QA
* Visit https:/
* Submit 6 translations/
* Verify the form does not oops.
LINT
lib/
lib/
TEST
./bin/test -vv -t TestCurrentTran
IMPLEMENTATION
Spent hours constructing a test to instrument the base view to reproduce the
the error. Moved the assertion before the loop to store the translations
since the work will be lost if there is an error. Lint reported:
1123: local variable 'translation' is assigned to but never used
Which reveals an if-statement and assignment have no purpose. I checked that
vars() and locals() were not used.
lib/
lib/