# Buggy code
def __init__(self, storefile, template_store=None, language_code=None):
    """Create file format object, wrapping up translate-toolkit's store."""
    self.storefile = storefile
    # Load store
    if isinstance(storefile, TranslationStore):
        # Used by XLSX writer
        self.store = storefile
    else:
        self.store = self.load(storefile)
    # Check store validity
    if not self.is_valid(self.store):
        raise ValueError("Invalid file format {0}".format(self.store))
    # Remember template
    self.template_store = template_store
    # Set language (needed for some which do not include this)
    if language_code is not None and self.store.gettargetlanguage() is None:
        self.store.settargetlanguage(language_code)


# Traceback (AssertionError)
======================================================================
FAIL: test_import_author (weblate.trans.tests.test_files.StringsImportTest)
Test importing normally.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/weblate/trans/tests/test_files.py", line 106, in test_import_author
self.assertEqual(translation.stats.translated, 1)
AssertionError: 0 != 1
======================================================================
FAIL: test_import_fuzzy (weblate.trans.tests.test_files.StringsImportTest)
Test importing as fuzzy.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/weblate/trans/tests/test_files.py", line 145, in test_import_fuzzy
self.assertEqual(unit.target, TRANSLATION_PO)
AssertionError: '' != 'Ahoj světe!\n'
+ Ahoj světe!
======================================================================
FAIL: test_import_normal (weblate.trans.tests.test_files.StringsImportTest)
Test importing normally.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/weblate/trans/tests/test_files.py", line 88, in test_import_normal
self.assertEqual(translation.stats.translated, 1)
AssertionError: 0 != 1
======================================================================
FAIL: test_import_overwrite (weblate.trans.tests.test_files.StringsImportTest)
Test importing with overwriting.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/weblate/trans/tests/test_files.py", line 124, in test_import_overwrite
self.assertEqual(unit.target, TRANSLATION_PO)
AssertionError: 'Nazdar světe!\n' != 'Ahoj světe!\n'
- Nazdar světe!
+ Ahoj světe!
======================================================================
FAIL: test_import_suggest (weblate.trans.tests.test_files.StringsImportTest)
Test importing as suggestion.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/weblate/trans/tests/test_files.py", line 170, in test_import_suggest
1
AssertionError: 0 != 1

# Fixed code
def __init__(self, storefile, template_store=None, language_code=None):
    """Create file format object, wrapping up translate-toolkit's store."""
    self.storefile = storefile
    # Load store
    if isinstance(storefile, TranslationStore):
        # Used by XLSX writer
        self.store = storefile
    else:
        self.store = self.load(storefile)
    # Check store validity
    if not self.is_valid(self.store):
        raise ValueError("Invalid file format {0}".format(repr(self.store)))
    # Remember template
    self.template_store = template_store
    # Set language (needed for some which do not include this)
    if language_code is not None and self.store.gettargetlanguage() is None:
        self.store.settargetlanguage(language_code)