diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-03-03 23:01:34 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-03-03 23:01:34 +0900 |
commit | dda98c7d53592a3f8e8e200e7295e77b5f1eb85d (patch) | |
tree | 5ae70a9b59a05bc68ac1760fa914ef32629a6a22 /tests/path.py | |
parent | 2a2da13cdef8b05bc034f00433cfc432f0447f7a (diff) | |
parent | 657c53b0f571fedcfa4cb347de7573a6dcfd1963 (diff) | |
download | sphinx-git-dda98c7d53592a3f8e8e200e7295e77b5f1eb85d.tar.gz |
Merge branch 'useless-test-noise'
Diffstat (limited to 'tests/path.py')
-rwxr-xr-x | tests/path.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/path.py b/tests/path.py index f4b2612f6..901c9ce96 100755 --- a/tests/path.py +++ b/tests/path.py @@ -12,7 +12,7 @@ import sys import shutil from io import open -from six import PY2, text_type +from six import PY2, text_type, binary_type FILESYSTEMENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding() @@ -143,7 +143,9 @@ class path(text_type): Returns the text in the file. """ with open(self, mode='U', encoding=encoding, **kwargs) as f: - return f.read() + text = f.read() + contents = repr_as(text, '<%s contents>' % self.basename()) + return contents def bytes(self): """ @@ -198,3 +200,18 @@ class path(text_type): def __repr__(self): return '%s(%s)' % (self.__class__.__name__, text_type.__repr__(self)) + + +# Lives here only to avoid circular references; use it from util.py! +class _repr_text(text_type): + def __repr__(self): + return self._repr +class _repr_bin(binary_type): + def __repr__(self): + return self._repr + +def repr_as(string, repr_): + wrapper = _repr_text if isinstance(string, text_type) else _repr_bin + proxy = wrapper(string) + proxy._repr = repr_ + return proxy |