diff options
author | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2012-05-01 15:13:06 +0900 |
---|---|---|
committer | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2012-05-01 15:13:06 +0900 |
commit | 1bb4923da1aa1878af44c4608d63025e4fae9d3b (patch) | |
tree | 555db29968bd2f149c3d04ddd90aba0fc7705fdb /tests | |
parent | 9af2094ca44265c892d59792156db4950475b18b (diff) | |
download | sphinx-git-1bb4923da1aa1878af44c4608d63025e4fae9d3b.tar.gz |
support multibyte filename handling.
https://bitbucket.org/birkenfeld/sphinx/issue/703
Diffstat (limited to 'tests')
-rw-r--r-- | tests/path.py | 12 | ||||
-rw-r--r-- | tests/test_build.py | 20 |
2 files changed, 26 insertions, 6 deletions
diff --git a/tests/path.py b/tests/path.py index 8e9afeaa8..bd0552d70 100644 --- a/tests/path.py +++ b/tests/path.py @@ -16,16 +16,16 @@ from codecs import open FILESYSTEMENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding() -class path(str): +class path(unicode): """ Represents a path which behaves like a string. """ if sys.version_info < (3, 0): def __new__(cls, s, encoding=FILESYSTEMENCODING, errors='strict'): - if isinstance(s, unicode): - s = s.encode(encoding, errors=errors) - return str.__new__(cls, s) - return str.__new__(cls, s) + if isinstance(s, str): + s = s.decode(encoding, errors) + return unicode.__new__(cls, s) + return unicode.__new__(cls, s) @property def parent(self): @@ -193,4 +193,4 @@ class path(str): __div__ = __truediv__ = joinpath def __repr__(self): - return '%s(%s)' % (self.__class__.__name__, str.__repr__(self)) + return '%s(%s)' % (self.__class__.__name__, unicode.__repr__(self)) diff --git a/tests/test_build.py b/tests/test_build.py index 5f24f89ac..ae3f29211 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -10,6 +10,7 @@ """ from util import * +from textwrap import dedent def teardown_module(): @@ -61,3 +62,22 @@ else: @with_app(buildername='singlehtml', cleanenv=True) def test_singlehtml(app): app.builder.build_all() + +@with_app(buildername='html', srcdir='(temp)') +def test_multibyte_path(app): + srcdir = path(app.srcdir) + mb_name = u'\u65e5\u672c\u8a9e' + (srcdir / mb_name).makedirs() + (srcdir / mb_name / (mb_name + '.txt')).write_text(dedent(""" + multi byte file name page + ========================== + """)) + + master_doc = srcdir / 'contents.txt' + master_doc.write_bytes((master_doc.text() + dedent(""" + .. toctree:: + + %(mb_name)s/%(mb_name)s + """ % locals()) + ).encode('utf-8')) + app.builder.build_all() |