diff options
Diffstat (limited to 'tests/test_util_i18n.py')
-rw-r--r-- | tests/test_util_i18n.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_util_i18n.py b/tests/test_util_i18n.py index e6e828efa..180350e86 100644 --- a/tests/test_util_i18n.py +++ b/tests/test_util_i18n.py @@ -4,7 +4,7 @@ Test i18n util. - :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. + :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -87,9 +87,17 @@ def test_format_date(): assert i18n.format_date(format, date=datet) == 'Feb 7, 2016, 5:11:17 AM' assert i18n.format_date(format, date=date) == 'Feb 7, 2016' + # timezone + format = '%Z' + assert i18n.format_date(format, date=datet) == 'UTC' + format = '%z' + assert i18n.format_date(format, date=datet) == '+0000' + @pytest.mark.xfail(os.name != 'posix', reason="Path separators don't match on windows") def test_get_filename_for_language(app): + app.env.temp_data['docname'] = 'index' + # language is None app.env.config.language = None assert app.env.config.language is None @@ -145,6 +153,17 @@ def test_get_filename_for_language(app): with pytest.raises(SphinxError): i18n.get_image_filename_for_language('foo.png', app.env) + # docpath (for a document in the top of source directory) + app.env.config.language = 'en' + app.env.config.figure_language_filename = '/{docpath}{language}/{basename}{ext}' + assert (i18n.get_image_filename_for_language('foo.png', app.env) == + '/en/foo.png') + + # docpath (for a document in the sub directory) + app.env.temp_data['docname'] = 'subdir/index' + assert (i18n.get_image_filename_for_language('foo.png', app.env) == + '/subdir/en/foo.png') + def test_CatalogRepository(tempdir): (tempdir / 'loc1' / 'xx' / 'LC_MESSAGES').makedirs() |