本文整理汇总了Python中translate.storage.test_base.headerless_len函数的典型用法代码示例。如果您正苦于以下问题:Python headerless_len函数的具体用法?Python headerless_len怎么用?Python headerless_len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了headerless_len函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: test_newlines
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
示例3: test_keep_translations
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
示例4: test_simplegrep_comments
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
示例5: test_simplegrep_locations
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: test_simplegrep_msgstr
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
示例7: test_unicode
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
示例8: test_empties
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
示例9: test_empties
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
示例10: 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
示例11: 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
示例12: test_non_existant_check
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
示例13: 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()
示例14: test_simplegrep_locations_with_comment_enabled
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
示例15: test_simplegrep_locations_with_comment_enabled
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