<s> """<STR_LIT>""" <EOL> import os <EOL> import unittest <EOL> from codecs import open <EOL> from py import path <EOL> import pytest <EOL> from igenstrings . merger import Merger <EOL> @ pytest . fixture ( autouse = True ) <EOL> def initdir ( tmpdir ) : <EOL> fixture_basename = '<STR_LIT>' <EOL> fixture_path = path . local ( fixture_basename ) <EOL> fixture_path . copy ( tmpdir / fixture_basename ) <EOL> tmpdir . chdir ( ) <EOL> def test_create_localizable_strings ( ) : <EOL> merger = Merger ( '<STR_LIT>' , None ) <EOL> merger . merge_localized_strings ( ) <EOL> assert os . path . exists ( '<STR_LIT>' ) <EOL> assert os . path . exists ( '<STR_LIT>' ) <EOL> content = None <EOL> with open ( '<STR_LIT>' , encoding = '<STR_LIT>' , mode = '<STR_LIT:r>' ) as en_locale_file : <EOL> content = en_locale_file . read ( ) <EOL> assert '<STR_LIT>' in content <EOL> def test_keep_existing_translated_strings ( ) : <EOL> merger = Merger ( '<STR_LIT>' , None ) <EOL> merger . merge_localized_strings ( ) <EOL> content = None <EOL> with open ( '<STR_LIT>' , encoding = '<STR_LIT>' , mode = '<STR_LIT:r>' ) as fr_locale_file : <EOL> content = fr_locale_file . read ( ) <EOL> assert '<STR_LIT>' in content <EOL> def test_merge_new_translated_strings ( ) : <EOL> merger = Merger ( '<STR_LIT>' , None ) <EOL> merger . merge_localized_strings ( ) <EOL> content = None <EOL> with open ( '<STR_LIT>' , encoding = '<STR_LIT>' , mode = '<STR_LIT:r>' ) as fr_locale_file : <EOL> content = fr_locale_file . read ( ) <EOL> assert '<STR_LIT>' in content <EOL> def test_linebreak_between_strings ( ) : <EOL> merger = Merger ( '<STR_LIT>' , None ) <EOL> merger . merge_localized_strings ( ) <EOL> content = None <EOL> with open ( '<STR_LIT>' , encoding = '<STR_LIT>' , mode = '<STR_LIT:r>' ) as en_locale_file : <EOL> content = en_locale_file . read ( ) <EOL> assert content == """<STR_LIT>""" <EOL> def test_cannot_parse_malformatted_strings ( ) : <EOL> merger = Merger ( '<STR_LIT>' , None ) <EOL> with pytest . raises ( Exception ) as excinfo : <EOL> merger . merge_localized_strings ( ) <EOL> assert isinstance ( excinfo . value , ValueError ) <EOL> def test_excluded_path ( ) : <EOL> merger = Merger ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> merger . merge_localized_strings ( ) <EOL> with open ( '<STR_LIT>' , encoding = '<STR_LIT>' , mode = '<STR_LIT:r>' ) as en_locale_file : <EOL> content = en_locale_file . read ( ) <EOL> assert '<STR_LIT>' not in content </s>
