• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_base.first_translatable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中translate.storage.test_base.first_translatable函数的典型用法代码示例。如果您正苦于以下问题:Python first_translatable函数的具体用法?Python first_translatable怎么用?Python first_translatable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了first_translatable函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_romanian_nicio

    def test_romanian_nicio(self):
        """Test the Romanian nicio check"""
        posource = '''
msgid "cow"
msgstr "bla nici o bla"
'''
        pofile = self.parse_text(posource)
        filter_result = self.filter(pofile,
                                    cmdlineoptions=["--language=ro",
                                                    "--test=niciun_nicio"])
        errors = first_translatable(filter_result).geterrors()
        assert len(errors) == 1
        assert 'niciun_nicio' in errors

        posource = '''
msgid "cow"
msgstr "bla nicio bla"
'''
        pofile = self.parse_text(posource)
        filter_result = self.filter(pofile,
                                    cmdlineoptions=["--language=ro",
                                                    "--test=niciun_nicio"])
        errors = first_translatable(filter_result).geterrors()
        assert len(errors) == 0
        assert 'niciun_nicio' not in errors
开发者ID:diorcety,项目名称:translate,代码行数:25,代码来源:test_pofilter.py


示例2: test_msgid_comments

 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
开发者ID:AndryulE,项目名称:kitsune,代码行数:8,代码来源:test_pofilter.py


示例3: test_simplegrep

    def test_simplegrep(self):
        """grep for a simple string."""
        xliff_text = self.xliff_text
        xliff_file = self.xliff_parse(xliff_text)
        xliff_result = self.xliff_parse(self.xliff_grep(xliff_text, "rêd"))
        assert first_translatable(xliff_result).getsource() == "rêd"
        assert first_translatable(xliff_result).gettarget() == "rooi"

        xliff_result = self.xliff_parse(self.xliff_grep(xliff_text, "unavailable string"))
        assert xliff_result.isempty()
开发者ID:onia,项目名称:translate,代码行数:10,代码来源:test_pogrep.py


示例4: test_ignore_if_already_marked

    def test_ignore_if_already_marked(self):
        """check that we don't add another failing marker if the message is already marked as failed"""
        self.unit.target = ''
        filter_result = self.filter(self.translationstore, cmdlineoptions=["--test=untranslated"])
        errors = first_translatable(filter_result).geterrors()
        assert len(errors) == 1
        assert errors.has_key('untranslated')

        # Run a filter test on the result, to check that it doesn't mark the same error twice.
        filter_result2 = self.filter(filter_result, cmdlineoptions=["--test=untranslated"])
        errors = first_translatable(filter_result2).geterrors()
        assert len(errors) == 1
        assert errors.has_key('untranslated')
开发者ID:AndryulE,项目名称:kitsune,代码行数:13,代码来源:test_pofilter.py


示例5: test_simplefail

 def test_simplefail(self):
     """checks that an obviously wrong string fails"""
     self.unit.target = "REST"
     filter_result = self.filter(self.translationstore)
     print filter_result
     print filter_result.units
     assert first_translatable(filter_result).geterrors().has_key('startcaps')
开发者ID:AndryulE,项目名称:kitsune,代码行数:7,代码来源:test_pofilter.py


示例6: test_notes

    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
开发者ID:AndryulE,项目名称:kitsune,代码行数:17,代码来源:test_pofilter.py


示例7: test_isreview

    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()
开发者ID:AndryulE,项目名称:kitsune,代码行数:8,代码来源:test_pofilter.py


示例8: test_preconditions

 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
开发者ID:AndryulE,项目名称:kitsune,代码行数:9,代码来源:test_pofilter.py


示例9: test_isfuzzy

    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
开发者ID:AndryulE,项目名称:kitsune,代码行数:10,代码来源:test_pofilter.py


示例10: test_translatorcomments

    def test_translatorcomments(self):
        """Tests translator comments"""
        minixlf = self.xliffskeleton % '''<trans-unit>
        <source>nonsense</source>
        <target>matlhapolosa</target>
        <context-group name="po-entry" purpose="information">
            <context context-type="x-po-trancomment">Couldn't do
it</context>
        </context-group>
        <note from="po-translator">Couldn't do
it</note>
</trans-unit>'''
        pofile = self.xliff2po(minixlf)
        assert pofile.translate("nonsense") == "matlhapolosa"
        assert pofile.translate("bla") is None
        unit = first_translatable(pofile)
        assert unit.getnotes("translator") == "Couldn't do it"
        potext = bytes(pofile).decode('utf-8')
        assert potext.index("# Couldn't do it\n") >= 0

        minixlf = self.xliffskeleton % '''<trans-unit xml:space="preserve">
        <source>nonsense</source>
        <target>matlhapolosa</target>
        <context-group name="po-entry" purpose="information">
            <context context-type="x-po-trancomment">Couldn't do
it</context>
        </context-group>
        <note from="po-translator">Couldn't do
it</note>
</trans-unit>'''
        pofile = self.xliff2po(minixlf)
        assert pofile.translate("nonsense") == "matlhapolosa"
        assert pofile.translate("bla") is None
        unit = first_translatable(pofile)
        assert unit.getnotes("translator") == "Couldn't do\nit"
        potext = bytes(pofile).decode('utf-8')
        assert potext.index("# Couldn't do\n# it\n") >= 0
开发者ID:Veterini,项目名称:translate,代码行数:37,代码来源:test_xliff2po.py


示例11: test_autocomment

    def test_autocomment(self):
        """Tests automatic comments"""
        minixlf = self.xliffskeleton % '''<trans-unit>
        <source>nonsense</source>
        <target>matlhapolosa</target>
        <context-group name="po-entry" purpose="information">
            <context context-type="x-po-autocomment">Note that this is
garbage</context>
        </context-group>
        <note from="developer">Note that this is
garbage</note>
</trans-unit>'''
        pofile = self.xliff2po(minixlf)
        assert pofile.translate("nonsense") == "matlhapolosa"
        assert pofile.translate("bla") is None
        unit = first_translatable(pofile)
        assert unit.getnotes("developer") == "Note that this is garbage"
        potext = bytes(pofile).decode('utf-8')
        assert potext.index("#. Note that this is garbage\n") >= 0

        minixlf = self.xliffskeleton % '''<trans-unit xml:space="preserve">
        <source>nonsense</source>
        <target>matlhapolosa</target>
        <context-group name="po-entry" purpose="information">
            <context context-type="x-po-autocomment">Note that this is
garbage</context>
        </context-group>
        <note from="developer">Note that this is
garbage</note>
</trans-unit>'''
        pofile = self.xliff2po(minixlf)
        assert pofile.translate("nonsense") == "matlhapolosa"
        assert pofile.translate("bla") is None
        unit = first_translatable(pofile)
        assert unit.getnotes("developer") == "Note that this is\ngarbage"
        potext = bytes(pofile).decode('utf-8')
        assert potext.index("#. Note that this is\n#. garbage\n") >= 0
开发者ID:Veterini,项目名称:translate,代码行数:37,代码来源:test_xliff2po.py


示例12: set_store_review

    def set_store_review(self, review=True):
        self.filetext = '''<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.1" xmlns="urn:oasis:names:tc:xliff:document:1.1">
<file datatype="po" original="example.po" source-language="en-US">
  <body>
    <trans-unit approved="yes">
      <source>test</source>
      <target>rest</target>
    </trans-unit>
  </body>
</file>
</xliff>'''

        self.translationstore = self.parse_text(self.filetext)
        self.unit = first_translatable(self.translationstore)
开发者ID:AndryulE,项目名称:kitsune,代码行数:15,代码来源:test_pofilter.py


示例13: test_quotes

    def test_quotes(self):
        """Test the escaping of quotes (and slash)"""
        minicsv = r''',"Hello ""Everyone""","Good day ""All"""
,"Use \"".","Gebruik \""."'''
        print(minicsv)
        csvfile = csvl10n.csvfile(wStringIO.StringIO(minicsv))
        print(bytes(csvfile))
        pofile = self.csv2po(minicsv)
        unit = first_translatable(pofile)
        assert unit.source == 'Hello "Everyone"'
        assert pofile.findunit('Hello "Everyone"').target == 'Good day "All"'
        print(bytes(pofile))
        for unit in pofile.units:
            print(unit.source)
            print(unit.target)
            print()
开发者ID:Veterini,项目名称:translate,代码行数:16,代码来源:test_csv2po.py


示例14: test_test_against_review

    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
开发者ID:AndryulE,项目名称:kitsune,代码行数:16,代码来源:test_pofilter.py


示例15: test_test_against_fuzzy

    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
开发者ID:AndryulE,项目名称:kitsune,代码行数:19,代码来源:test_pofilter.py


示例16: test_locations

    def test_locations(self):
        """Tests location comments (#:)"""
        minixlf = self.xliffskeleton % '''<trans-unit id="1">
        <source>nonsense</source>
        <target>matlhapolosa</target>
        <context-group name="po-reference" purpose="location">
            <context context-type="sourcefile">example.c</context>
            <context context-type="linenumber">123</context>
            </context-group>
        <context-group name="po-reference" purpose="location">
            <context context-type="sourcefile">place.py</context>
        </context-group>
</trans-unit>'''
        pofile = self.xliff2po(minixlf)
        assert pofile.translate("nonsense") == "matlhapolosa"
        assert pofile.translate("bla") is None
        unit = first_translatable(pofile)
        locations = unit.getlocations()
        assert len(locations) == 2
        assert "example.c:123" in locations
        assert "place.py" in locations
开发者ID:Veterini,项目名称:translate,代码行数:21,代码来源:test_xliff2po.py


示例17: setup_method

 def setup_method(self, method):
     self.translationstore = self.parse_text(self.filetext)
     self.unit = first_translatable(self.translationstore)
开发者ID:AndryulE,项目名称:kitsune,代码行数:3,代码来源:test_pofilter.py


示例18: singleelement

 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)
开发者ID:Jobava,项目名称:translate-toolkit,代码行数:4,代码来源:test_po2csv.py



注:本文中的translate.storage.test_base.first_translatable函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_base.headerless_len函数代码示例发布时间:2022-05-27
下一篇:
Python pypo.quoteforpo函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap