Пример #1
0
def test_merge_new_translated_strings():
    merger = Merger('tests/src/objc/existing', None)
    merger.merge_localized_strings()
    content = None
    with open('tests/src/objc/existing/fr.lproj/Localizable.strings', encoding='utf8', mode='r') as fr_locale_file:
        content = fr_locale_file.read()
    assert 'How are you doing' in content
Пример #2
0
def test_escape_linebreaks():
    merger = Merger('tests/src/objc/linebreaks', None)
    merger.merge_localized_strings()
    content = None
    with open('tests/src/objc/linebreaks/en.lproj/Localizable.strings', encoding='utf8', mode='r') as en_locale_file:
        content = en_locale_file.read()
    assert content == """/* title for the simple object */
Пример #3
0
def test_works_with_ascii_encoding():
    merger = Merger('tests/src/objc/ascii', None)
    merger.merge_localized_strings()
    content = None
    with open('tests/src/objc/ascii/fr.lproj/Localizable.strings', encoding='utf8', mode='r') as fr_locale_file:
        content = fr_locale_file.read()
    assert 'Bonjour' in content
Пример #4
0
def test_create_localizable_strings_for_objc():
    merger = Merger('tests/src/objc/new', None)
    merger.merge_localized_strings()
    assert os.path.exists('tests/src/objc/new/en.lproj/Localizable.strings')
    assert os.path.exists('tests/src/objc/new/fr.lproj/Localizable.strings')
    content = None
    with open('tests/src/objc/new/en.lproj/Localizable.strings', encoding='utf8', mode='r') as en_locale_file:
        content = en_locale_file.read()
    assert 'Hi' in content
Пример #5
0
def test_merge_new_translated_strings():
    merger = Merger('tests/src/objc/existing', None)
    merger.merge_localized_strings()
    content = None
    with open('tests/src/objc/existing/fr.lproj/Localizable.strings',
              encoding='utf8',
              mode='r') as fr_locale_file:
        content = fr_locale_file.read()
    assert 'How are you doing' in content
Пример #6
0
def test_escape_linebreaks():
    merger = Merger('tests/src/objc/linebreaks', None)
    merger.merge_localized_strings()
    content = None
    with open('tests/src/objc/linebreaks/en.lproj/Localizable.strings',
              encoding='utf8',
              mode='r') as en_locale_file:
        content = en_locale_file.read()
    assert content == """/* title for the simple object */
Пример #7
0
def test_works_with_ascii_encoding():
    merger = Merger('tests/src/objc/ascii', None)
    merger.merge_localized_strings()
    content = None
    with open('tests/src/objc/ascii/fr.lproj/Localizable.strings',
              encoding='utf8',
              mode='r') as fr_locale_file:
        content = fr_locale_file.read()
    assert 'Bonjour' in content
Пример #8
0
def test_excluded_path():
    merger = Merger('tests/src/objc/exclusion',
                    ['tests/src/objc/exclusion/ExcludedDirectory/*.m'])
    merger.merge_localized_strings()
    with open('tests/src/objc/exclusion/en.lproj/Localizable.strings',
              encoding='utf8',
              mode='r') as en_locale_file:
        content = en_locale_file.read()
    assert 'Should be excluded from localization' not in content
Пример #9
0
def test_create_localizable_strings_for_objc():
    merger = Merger('tests/src/objc/new', None)
    merger.merge_localized_strings()
    assert os.path.exists('tests/src/objc/new/en.lproj/Localizable.strings')
    assert os.path.exists('tests/src/objc/new/fr.lproj/Localizable.strings')
    content = None
    with open('tests/src/objc/new/en.lproj/Localizable.strings',
              encoding='utf8',
              mode='r') as en_locale_file:
        content = en_locale_file.read()
    assert 'Hi' in content
Пример #10
0
def test_cannot_parse_malformatted_strings():
    merger = Merger('tests/src/objc/malformatted', None)
    with pytest.raises(Exception) as excinfo:
        merger.merge_localized_strings()
    assert isinstance(excinfo.value, ValueError)
Пример #11
0
def test_raise_error_with_utf16_encoding():
    merger = Merger('tests/src/objc/utf16', None)
    with pytest.raises(Exception) as excinfo:
        merger.merge_localized_strings()
    assert isinstance(excinfo.value, ValueError)
Пример #12
0
def test_excluded_path():
    merger = Merger('tests/src/objc/exclusion', ['tests/src/objc/exclusion/ExcludedDirectory/*.m'])
    merger.merge_localized_strings()
    with open('tests/src/objc/exclusion/en.lproj/Localizable.strings', encoding='utf8', mode='r') as en_locale_file:
        content = en_locale_file.read()
    assert 'Should be excluded from localization' not in content
Пример #13
0
def test_raise_error_with_utf16_encoding():
    merger = Merger('tests/src/objc/utf16', None)
    with pytest.raises(Exception) as excinfo:
        merger.merge_localized_strings()
    assert isinstance(excinfo.value, ValueError)
Пример #14
0
def test_cannot_parse_malformatted_strings():
    merger = Merger('tests/src/objc/malformatted', None)
    with pytest.raises(Exception) as excinfo:
        merger.merge_localized_strings()
    assert isinstance(excinfo.value, ValueError)