mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Test translation patching in vitro.
This commit is contained in:
parent
4b8249e6b1
commit
1433b5cb11
12
tests/root/bom.po
Normal file
12
tests/root/bom.po
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
msgid "File with UTF-8 BOM"
|
||||||
|
msgstr "Datei mit UTF-8 BOM"
|
||||||
|
|
||||||
|
msgid "This file has a UTF-8 \"BOM\"."
|
||||||
|
msgstr "This file has umlauts: äöü."
|
@ -70,3 +70,30 @@ def test_gettext(app):
|
|||||||
@with_app(buildername='gettext')
|
@with_app(buildername='gettext')
|
||||||
def test_all(app):
|
def test_all(app):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
|
|
||||||
|
@with_app(buildername='text',
|
||||||
|
confoverrides={'language': 'xx', 'locale_dirs': ['.']})
|
||||||
|
def test_patch(app):
|
||||||
|
app.builder.build(['bom'])
|
||||||
|
res = (app.outdir / 'bom.txt').text('utf-8')
|
||||||
|
assert res == u"Datei mit UTF-8 BOM\n\nThis file has umlauts: äöü.\n"
|
||||||
|
|
||||||
|
def setup_patch():
|
||||||
|
(test_root / 'xx' / 'LC_MESSAGES').makedirs()
|
||||||
|
try:
|
||||||
|
p = Popen(['msgfmt', test_root / 'bom.po', '-o',
|
||||||
|
test_root / 'xx' / 'LC_MESSAGES' / 'bom.mo'],
|
||||||
|
stdout=PIPE, stderr=PIPE)
|
||||||
|
except OSError:
|
||||||
|
return # most likely msgfmt was not found
|
||||||
|
else:
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
if p.returncode != 0:
|
||||||
|
print stdout
|
||||||
|
print stderr
|
||||||
|
assert False, 'msgfmt exited with return code %s' % p.returncode
|
||||||
|
assert (test_root / 'xx' / 'LC_MESSAGES' / 'bom.mo').isfile(), 'msgfmt failed'
|
||||||
|
def teardown_patch():
|
||||||
|
(test_root / 'xx').rmtree()
|
||||||
|
test_patch.setup = setup_patch
|
||||||
|
test_patch.teardown = teardown_patch
|
||||||
|
Loading…
Reference in New Issue
Block a user