[FIX] test_lint: check for duplicate entries in POT files
X-original-commit: 4e29fbada592e887459dabee71708c6d0dd01715
This commit is contained in:
@@ -559,6 +559,7 @@ msgstr ""
|
||||
msgid "type: [(name, amount, base, formated amount, formated base)]"
|
||||
msgstr ""
|
||||
|
||||
#. module: l10n_ch
|
||||
#: code:addons/l10n_ch/models/account_invoice.py:179
|
||||
#, python-format
|
||||
msgid "Cannot generate the QR-bill. Please check you have configured the address of your company and debtor. If you are using a QR-IBAN, also check the invoice's payment reference is a QR reference."
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from . import test_pylint
|
||||
from . import test_pofile
|
||||
from . import test_ecmascript
|
||||
from . import test_markers
|
||||
from . import test_onchange_domains
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from collections import Counter
|
||||
|
||||
from odoo.modules import get_modules, get_resource_path
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.tools.translate import TranslationFileReader
|
||||
|
||||
|
||||
class PotLinter(TransactionCase):
|
||||
def test_pot_duplicate_entries(self):
|
||||
def format(entry):
|
||||
# TranslationFileReader only returns those three types
|
||||
if entry['type'] == 'model':
|
||||
return ('model', entry['name'], entry['imd_name'])
|
||||
elif entry['type'] == 'model_terms':
|
||||
return ('model_terms', entry['name'], entry['imd_name'], entry['src'])
|
||||
elif entry['type'] == 'code':
|
||||
return ('code', entry['src'])
|
||||
|
||||
# retrieve all modules, and their corresponding POT file
|
||||
for module in get_modules():
|
||||
filename = get_resource_path(module, 'i18n', module + '.pot')
|
||||
if not filename:
|
||||
continue
|
||||
counts = Counter(map(format, TranslationFileReader(filename)))
|
||||
duplicates = [key for key, count in counts.items() if count > 1]
|
||||
self.assertFalse(duplicates, "Duplicate entries found in %s" % filename)
|
||||
Reference in New Issue
Block a user