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
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 */
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
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
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
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)
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)