コード例 #1
0
ファイル: test_pofilter.py プロジェクト: mozilla/markup-lib
 def test_msgid_comments(self):
     """Tests that msgid comments don't feature anywhere."""
     posource = 'msgid "_: Capital.  ACRONYMN. (msgid) comment 3. %d Extra sentence.\\n"\n"cow"\nmsgstr "koei"\n'
     pofile = self.parse_text(posource)
     filter_result = self.filter(pofile)
     if headerless_len(filter_result.units):
         print first_translatable(filter_result)
     assert headerless_len(filter_result.units) == 0
コード例 #2
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
 def test_msgid_comments(self):
     """Tests that msgid comments don't feature anywhere."""
     posource = 'msgid "_: Capital.  ACRONYMN. (msgid) comment 3. %d Extra sentence.\\n"\n"cow"\nmsgstr "koei"\n'
     pofile = self.parse_text(posource)
     filter_result = self.filter(pofile)
     if headerless_len(filter_result.units):
         print first_translatable(filter_result)
     assert headerless_len(filter_result.units) == 0
コード例 #3
0
ファイル: test_csv2po.py プロジェクト: diorcety/translate
 def test_newlines(self):
     """Tests that things keep working with empty entries"""
     minicsv = '"source","target"\r\n"yellow pencil","żółty\\nołówek"'
     pofile = self.csv2po(minicsv)
     assert pofile.findunit("yellow pencil") is not None
     assert pofile.findunit("yellow pencil").target == "żółty\\nołówek"
     assert headerless_len(pofile.units) == 1
コード例 #4
0
 def test_unicode(self):
     """tests that we can handle UTF-8 encoded characters when there is no
     known header specified encoding"""
     self.unit.source = u'Bézier curve'
     self.unit.target = u'Bézier-kurwe'
     filter_result = self.filter(self.translationstore)
     assert headerless_len(filter_result.units) == 0
コード例 #5
0
ファイル: test_pogrep.py プロジェクト: onia/translate
 def test_simplegrep_locations(self):
     """grep for a string in the location comments"""
     posource = '#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "test.c", ["--search=locations"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "rest.c", ["--search=locations"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #6
0
ファイル: test_pofilter.py プロジェクト: nguyenngan/translate
 def test_non_existant_check(self):
     """check that we report an error if a user tries to run a non-existant test"""
     filter_result = self.filter(self.translationstore,
                                 cmdlineoptions=["-t nonexistant"])
     # TODO Not sure how to check for the stderror result of: warning: could
     # not find filter  nonexistant
     assert headerless_len(filter_result.units) == 0
コード例 #7
0
 def test_empties(self):
     """Tests that things keep working with empty entries"""
     minipo = 'msgid "Source"\nmsgstr ""\n\nmsgid ""\nmsgstr ""'
     csvfile = self.po2csv(minipo)
     assert csvfile.findunit("Source") is not None
     assert csvfile.findunit("Source").target == ""
     assert headerless_len(csvfile.units) == 1
コード例 #8
0
ファイル: test_csv2po.py プロジェクト: Veterini/translate
 def test_empties(self):
     """Tests that things keep working with empty entries"""
     minicsv = ',SomeSource,'
     pofile = self.csv2po(minicsv)
     assert pofile.findunit("SomeSource") is not None
     assert pofile.findunit("SomeSource").target == ""
     assert headerless_len(pofile.units) == 1
コード例 #9
0
ファイル: test_pogrep.py プロジェクト: onia/translate
 def test_keep_translations(self):
     """check that we can grep unicode messages and use unicode regex search strings"""
     posource = '#: schemas.in\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "schemas.in", ["--invert-match", "--keep-translations", "--search=locations"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "schemas.in", ["--invert-match", "--search=locations"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #10
0
ファイル: test_pogrep.py プロジェクト: zbj00/translate
 def test_simplegrep_locations(self):
     """grep for a string in the location comments"""
     posource = '#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "test.c", ["--search=locations"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "rest.c", ["--search=locations"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #11
0
 def test_empties(self):
     """Tests that things keep working with empty entries"""
     minicsv = ',SomeSource,'
     pofile = self.csv2po(minicsv)
     assert pofile.findunit("SomeSource") is not None
     assert pofile.findunit("SomeSource").target == ""
     assert headerless_len(pofile.units) == 1
コード例 #12
0
ファイル: test_csv2po.py プロジェクト: cuonganh/translate
 def test_escaped_newlines(self):
     """Tests that things keep working with escaped newlines"""
     minicsv = '"source","target"\r\n"yellow pencil","żółty\\nołówek"'
     pofile = self.csv2po(minicsv)
     assert pofile.findunit("yellow pencil") is not None
     assert pofile.findunit("yellow pencil").target == "żółty\\nołówek"
     assert headerless_len(pofile.units) == 1
コード例 #13
0
ファイル: test_pogrep.py プロジェクト: zbj00/translate
 def test_simplegrep_comments(self):
     """grep for a string in the comments"""
     posource = '# (review) comment\n#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "review", ["--search=comment"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "test", ["--search=comment"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #14
0
ファイル: test_pogrep.py プロジェクト: onia/translate
 def test_simplegrep_comments(self):
     """grep for a string in the comments"""
     posource = '# (review) comment\n#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "review", ["--search=comment"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "test", ["--search=comment"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #15
0
ファイル: test_pogrep.py プロジェクト: onia/translate
 def test_simplegrep_msgstr(self):
     """grep for a string in the target"""
     posource = '#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "rest", ["--search=msgstr"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "test", ["--search=msgstr"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #16
0
 def test_keep_translations(self):
     """check that we can grep unicode messages and use unicode regex search strings"""
     posource = '#: schemas.in\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "schemas.in", ["--invert-match", "--keep-translations", "--search=locations"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "schemas.in", ["--invert-match", "--search=locations"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #17
0
ファイル: test_pofilter.py プロジェクト: Veterini/translate
 def test_unicode(self):
     """tests that we can handle UTF-8 encoded characters when there is no
     known header specified encoding"""
     self.unit.source = u'Bézier curve'
     self.unit.target = u'Bézier-kurwe'
     filter_result = self.filter(self.translationstore)
     assert headerless_len(filter_result.units) == 0
コード例 #18
0
ファイル: test_pogrep.py プロジェクト: zbj00/translate
 def test_simplegrep_msgstr(self):
     """grep for a string in the target"""
     posource = '#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "rest", ["--search=msgstr"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "test", ["--search=msgstr"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #19
0
ファイル: test_po2csv.py プロジェクト: slide333333/translate
 def test_empties(self):
     """Tests that things keep working with empty entries"""
     minipo = 'msgid "Source"\nmsgstr ""\n\nmsgid ""\nmsgstr ""'
     csvfile = self.po2csv(minipo)
     assert csvfile.findunit("Source") is not None
     assert csvfile.findunit("Source").target == ""
     assert headerless_len(csvfile.units) == 1
コード例 #20
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
    def test_test_against_review(self):
        """test whether to run tests against translations marked for review"""
        self.unit.markreviewneeded()
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--review"])
        assert first_translatable(filter_result).isreview()

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--noreview"])
        assert headerless_len(filter_result.units) == 0

        # Re-initialize the translation store object.
        self.setup_method(self)

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--review"])
        assert headerless_len(filter_result.units) == 0
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--noreview"])
        assert headerless_len(filter_result.units) == 0
コード例 #21
0
    def test_notes(self):
        """tests the optional adding of notes"""
        # let's make sure we trigger the 'long' and/or 'doubleword' test
        self.unit.target = "asdf asdf asdf asdf asdf asdf asdf"
        filter_result = self.filter(self.translationstore)
        assert headerless_len(filter_result.units) == 1
        assert first_translatable(filter_result).geterrors()

        # now we remove the existing error. self.unit is changed since we copy
        # units - very naughty
        if isinstance(self.unit, xliff.xliffunit):
            self.unit.removenotes(origin="pofilter")
        else:
            self.unit.removenotes()
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--nonotes"])
        assert headerless_len(filter_result.units) == 1
        assert len(first_translatable(filter_result).geterrors()) == 0
コード例 #22
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
    def test_isreview(self):
        """tests the extraction of items marked review"""
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--test=isreview"])
        assert headerless_len(filter_result.units) == 0

        self.unit.markreviewneeded()
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--test=isreview"])
        assert first_translatable(filter_result).isreview()
コード例 #23
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
    def test_notes(self):
        """tests the optional adding of notes"""
        # let's make sure we trigger the 'long' and/or 'doubleword' test
        self.unit.target = u"asdf asdf asdf asdf asdf asdf asdf"
        filter_result = self.filter(self.translationstore)
        assert headerless_len(filter_result.units) == 1
        assert first_translatable(filter_result).geterrors()

        # now we remove the existing error. self.unit is changed since we copy
        # units - very naughty
        if isinstance(self.unit, xliff.xliffunit):
            self.unit.removenotes(origin='pofilter')
        else:
            self.unit.removenotes()
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--nonotes"])
        assert headerless_len(filter_result.units) == 1
        assert len(first_translatable(filter_result).geterrors()) == 0
コード例 #24
0
ファイル: test_pofilter.py プロジェクト: Veterini/translate
 def test_non_existant_check(self):
     """check that we report an error if a user tries to run a non-existant
     test"""
     filter_result = self.filter(self.translationstore,
                                 cmdlineoptions=["-t nonexistant"])
     # TODO Not sure how to check for the stderror result of: warning: could
     # not find filter  nonexistant
     assert headerless_len(filter_result.units) == 0
コード例 #25
0
 def test_preconditions(self):
     """tests that the preconditions work correctly"""
     self.unit.source = "File"
     self.unit.target = ""
     filter_result = self.filter(self.translationstore)
     # We should only get one error (untranslated), and nothing else
     assert headerless_len(filter_result.units) == 1
     unit = first_translatable(filter_result)
     assert len(unit.geterrors()) == 1
コード例 #26
0
ファイル: test_pogrep.py プロジェクト: onia/translate
 def test_simplegrep_locations_with_comment_enabled(self):
     """grep for a string in "locations", while also "comment" is checked
     see http://bugs.locamotion.org/show_bug.cgi?id=1036
     """
     posource = '# (review) comment\n#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "test", ["--search=comment", "--search=locations"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "rest", ["--search=comment", "--search=locations"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #27
0
 def test_simplegrep_locations_with_comment_enabled(self):
     """grep for a string in "locations", while also "comment" is checked
     see https://github.com/translate/translate/issues/1036
     """
     posource = '# (review) comment\n#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "test", ["--search=comment", "--search=locations"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "rest", ["--search=comment", "--search=locations"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #28
0
 def test_minimal(self):
     minixlf = self.xliffskeleton % '''<trans-unit>
     <source>red</source>
     <target>rooi</target>
   </trans-unit>'''
     pofile = self.xliff2po(minixlf)
     assert headerless_len(pofile.units) == 1
     assert pofile.translate("red") == "rooi"
     assert pofile.translate("bla") is None
コード例 #29
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
 def test_preconditions(self):
     """tests that the preconditions work correctly"""
     self.unit.source = "File"
     self.unit.target = ""
     filter_result= self.filter(self.translationstore)
     # We should only get one error (untranslated), and nothing else
     assert headerless_len(filter_result.units) == 1
     unit = first_translatable(filter_result)
     assert len(unit.geterrors()) == 1
コード例 #30
0
ファイル: test_pogrep.py プロジェクト: alexbriski/pootleDev
 def test_simplegrep_locations_with_comment_enabled(self):
     """grep for a string in "locations", while also "comment" is checked
     see http://bugs.locamotion.org/show_bug.cgi?id=1036
     """
     posource = '# (review) comment\n#: test.c\nmsgid "test"\nmsgstr "rest"\n'
     poresult = self.pogrep(posource, "test", ["--search=comment", "--search=locations"])
     assert poresult.index(posource) >= 0
     poresult = self.pogrep(posource, "rest", ["--search=comment", "--search=locations"])
     assert headerless_len(po.pofile(poresult).units) == 0
コード例 #31
0
    def test_test_against_fuzzy(self):
        """test whether to run tests against fuzzy translations"""
        self.unit.markfuzzy()

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--fuzzy"])
        assert "isfuzzy" in first_translatable(filter_result).geterrors()

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--nofuzzy"])
        assert headerless_len(filter_result.units) == 0

        # Re-initialize the translation store object in order to get an unfuzzy
        # unit with no filter notes.
        self.setup_method(self)

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--fuzzy"])
        assert headerless_len(filter_result.units) == 0

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--nofuzzy"])
        assert headerless_len(filter_result.units) == 0
コード例 #32
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
    def test_test_against_fuzzy(self):
        """test whether to run tests against fuzzy translations"""
        self.unit.markfuzzy()

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--fuzzy"])
        assert first_translatable(filter_result).geterrors().has_key('isfuzzy')

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--nofuzzy"])
        assert headerless_len(filter_result.units) == 0

        # Re-initialize the translation store object in order to get an unfuzzy unit
	# with no filter notes.
        self.setup_method(self)

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--fuzzy"])
        assert headerless_len(filter_result.units) == 0

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--nofuzzy"])
        assert headerless_len(filter_result.units) == 0
コード例 #33
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
    def test_isfuzzy(self):
        """tests the extraction of items marked fuzzy"""
        self.unit.markfuzzy()

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--test=isfuzzy"])
        assert first_translatable(filter_result).geterrors().has_key('isfuzzy')

        self.unit.markfuzzy(False)
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--test=isfuzzy"])
        assert headerless_len(filter_result.units) == 0
コード例 #34
0
    def test_isreview(self):
        """tests the extraction of items marked review"""
        filter_result = self.filter(self.translationstore,
                                    cmdlineoptions=["--test=isreview"])
        assert headerless_len(filter_result.units) == 0

        self.unit.markreviewneeded()
        filter_result = self.filter(self.translationstore,
                                    cmdlineoptions=["--test=isreview"])
        assert first_translatable(filter_result).isreview()
コード例 #35
0
    def test_test_against_review(self):
        """test whether to run tests against translations marked for review"""
        self.unit.markreviewneeded()
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--review"])
        assert first_translatable(filter_result).isreview()

        filter_result = self.filter(
            self.translationstore, cmdlineoptions=["--noreview"]
        )
        assert headerless_len(filter_result.units) == 0

        # Re-initialize the translation store object.
        self.setup_method(self)

        filter_result = self.filter(self.translationstore, cmdlineoptions=["--review"])
        assert headerless_len(filter_result.units) == 0
        filter_result = self.filter(
            self.translationstore, cmdlineoptions=["--noreview"]
        )
        assert headerless_len(filter_result.units) == 0
コード例 #36
0
    def test_isfuzzy(self):
        """tests the extraction of items marked fuzzy"""
        self.unit.markfuzzy()

        filter_result = self.filter(self.translationstore,
                                    cmdlineoptions=["--test=isfuzzy"])
        assert "isfuzzy" in first_translatable(filter_result).geterrors()

        self.unit.markfuzzy(False)
        filter_result = self.filter(self.translationstore,
                                    cmdlineoptions=["--test=isfuzzy"])
        assert headerless_len(filter_result.units) == 0
コード例 #37
0
ファイル: test_resx2po.py プロジェクト: Veterini/translate
    def test_simple(self):
        """ Test the most basic resx conversion """
        resx_source = self.XMLskeleton % '''<data name="key" xml:space="preserve">
        <value>A simple string</value>
        </data>'''
        poexpected = '''#: key
msgid "A simple string"
msgstr ""
'''
        po_result = self.resx2po(resx_source)

        assert str(po_result.units[1]) == poexpected
        assert headerless_len(po_result.units) == 1
コード例 #38
0
ファイル: test_resx2po.py プロジェクト: uniqx/translate
    def test_simple(self):
        """ Test the most basic resx conversion """
        resx_source = self.XMLskeleton % '''<data name="key" xml:space="preserve">
        <value>A simple string</value>
        </data>'''
        poexpected = '''#: key
msgid "A simple string"
msgstr ""
'''
        po_result = self.resx2po(resx_source)

        assert str(po_result.units[1]) == poexpected
        assert headerless_len(po_result.units) == 1
コード例 #39
0
    def test_plurals(self):
        """Tests fuzzyness"""
        minixlf = self.xliffskeleton % '''<group id="1" restype="x-gettext-plurals">
        <trans-unit id="1[0]" xml:space="preserve">
            <source>cow</source>
            <target>inkomo</target>
        </trans-unit>
        <trans-unit id="1[1]" xml:space="preserve">
            <source>cows</source>
            <target>iinkomo</target>
        </trans-unit>
</group>'''
        pofile = self.xliff2po(minixlf)
        print(bytes(pofile))
        potext = bytes(pofile).decode('utf-8')
        assert headerless_len(pofile.units) == 1
        assert potext.index('msgid_plural "cows"')
        assert potext.index('msgstr[0] "inkomo"')
        assert potext.index('msgstr[1] "iinkomo"')
コード例 #40
0
 def test_fuzzy(self):
     """Tests fuzzyness"""
     minixlf = self.xliffskeleton % '''<trans-unit approved="no">
         <source>book</source>
     </trans-unit>
     <trans-unit id="2" approved="yes">
         <source>nonsense</source>
         <target>matlhapolosa</target>
     </trans-unit>
     <trans-unit id="2" approved="no">
         <source>verb</source>
         <target state="needs-review-translation">lediri</target>
     </trans-unit>'''
     pofile = self.xliff2po(minixlf)
     assert pofile.translate("nonsense") == "matlhapolosa"
     assert pofile.translate("verb") == "lediri"
     assert pofile.translate("book") is None
     assert pofile.translate("bla") is None
     assert headerless_len(pofile.units) == 3
     #TODO: decide if this one should be fuzzy:
     #assert pofile.units[0].isfuzzy()
     assert not pofile.units[2].isfuzzy()
     assert pofile.units[3].isfuzzy()
コード例 #41
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
 def test_list_all_tests(self):
     """lists all available tests"""
     filter_result = self.filter(self.translationstore, cmdlineoptions=["-l"])
     # TODO again not sure how to check the stderror output
     assert headerless_len(filter_result.units) == 0
コード例 #42
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
 def test_variables_across_lines(self):
     """Test that variables can span lines and still fail/pass"""
     self.unit.source = '"At &timeBombURL."\n"label;."'
     self.unit.target = '"Tydens &tydBombURL."\n"etiket;."'
     filter_result = self.filter(self.translationstore)
     assert headerless_len(filter_result.units) == 0
コード例 #43
0
ファイル: test_pofilter.py プロジェクト: AndryulE/kitsune
 def test_simplepass(self):
     """checks that an obviously correct string passes"""
     filter_result = self.filter(self.translationstore)
     assert headerless_len(filter_result.units) == 0
コード例 #44
0
 def test_list_all_tests(self):
     """lists all available tests"""
     filter_result = self.filter(self.translationstore, cmdlineoptions=["-l"])
     # TODO again not sure how to check the stderror output
     assert headerless_len(filter_result.units) == 0
コード例 #45
0
 def singleelement(self, storage):
     """checks that the pofile contains a single non-header element, and returns it"""
     assert headerless_len(storage.units) == 1
     return first_translatable(storage)
コード例 #46
0
ファイル: test_po2csv.py プロジェクト: slide333333/translate
 def singleelement(self, storage):
     """checks that the pofile contains a single non-header element, and returns it"""
     assert headerless_len(storage.units) == 1
     return first_translatable(storage)
コード例 #47
0
 def test_variables_across_lines(self):
     """Test that variables can span lines and still fail/pass"""
     self.unit.source = '"At &timeBombURL."\n"label;."'
     self.unit.target = '"Tydens &tydBombURL."\n"etiket;."'
     filter_result = self.filter(self.translationstore)
     assert headerless_len(filter_result.units) == 0
コード例 #48
0
 def test_simplepass(self):
     """checks that an obviously correct string passes"""
     filter_result = self.filter(self.translationstore)
     assert headerless_len(filter_result.units) == 0