<commit_before>import os
import sys
import glob
import re
import polib
import nose
from collections import Counter

re_python_new = re.compile(r'\{(\w*)\}')
re_python_old = re.compile(r'%(?:\((\w+)\))?(\w+)')


def get_language_code(filename):
    filename = os.path.split(filename)[0]
    filename = os.path.split(filename)[0]
    filename = os.path.split(filename)[1]
    return filename


def test_pofiles():
    for filename in glob.glob(os.path.join('skylines', 'i18n', '*', 'LC_MESSAGES', 'skylines.po')):
        test_pofiles.func_doc = ('Python string format placeholders must match '
                                 '(lang: {})'.format(get_language_code(filename)))
        yield check_pofile, filename


def check_pofile(filename):
    po = polib.pofile(filename)
    for entry in po.translated_entries():
        if not entry.obsolete and not entry.msgstr == '':
            check_placeholders(filename, entry.msgid, entry.msgstr)


def check_placeholders(filename, msgid, msgstr):
    check_python(filename, msgid, msgstr, re_python_new)
    check_python(filename, msgid, msgstr, re_python_old)
<commit_msg>tests: Fixed test_i18n unit test<commit_after>import os
import sys
import glob
import re
import polib
import nose
from collections import Counter

re_python_new = re.compile(r'\{(\w*)\}')
re_python_old = re.compile(r'%(?:\((\w+)\))?(\w+)')


def get_language_code(filename):
    filename = os.path.split(filename)[0]
    filename = os.path.split(filename)[0]
    filename = os.path.split(filename)[1]
    return filename


def test_pofiles():
    for filename in glob.glob(os.path.join('skylines', 'translations', '*', 'LC_MESSAGES', 'messages.po')):
        test_pofiles.func_doc = ('Python string format placeholders must match '
                                 '(lang: {})'.format(get_language_code(filename)))
        yield check_pofile, filename


def check_pofile(filename):
    po = polib.pofile(filename)
    for entry in po.translated_entries():
        if not entry.obsolete and not entry.msgstr == '':
            check_placeholders(filename, entry.msgid, entry.msgstr)


def check_placeholders(filename, msgid, msgstr):
    check_python(filename, msgid, msgstr, re_python_new)
    check_python(filename, msgid, msgstr, re_python_old)

{'fraction_non_alphanumeric': 0.13277459197176886, 'fraction_numerical': 0.004411116012351125, 'mean_word_length': 3.8358208955223883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7291357', 'n_tokens_mistral': 754, 'n_tokens_neox': 718, 'n_words': 164}