本文整理汇总了Python中pystache.loader.Loader.read方法的典型用法代码示例。如果您正苦于以下问题:Python Loader.read方法的具体用法?Python Loader.read怎么用?Python Loader.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pystache.loader.Loader
的用法示例。
在下文中一共展示了Loader.read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read
# 需要导入模块: from pystache.loader import Loader [as 别名]
# 或者: from pystache.loader.Loader import read [as 别名]
def test_read(self):
"""
Test read().
"""
loader = Loader()
path = self._get_path('ascii.mustache')
actual = loader.read(path)
self.assertString(actual, 'ascii: abc')
示例2: test_read
# 需要导入模块: from pystache.loader import Loader [as 别名]
# 或者: from pystache.loader.Loader import read [as 别名]
def test_read(self):
"""
Test read().
"""
reader = Loader()
path = self._get_path("ascii.mustache")
actual = reader.read(path)
self.assertString(actual, u"ascii: abc")
示例3: test_read__encoding__argument
# 需要导入模块: from pystache.loader import Loader [as 别名]
# 或者: from pystache.loader.Loader import read [as 别名]
def test_read__encoding__argument(self):
"""
Test read(): encoding argument respected.
"""
loader = Loader()
path = self._get_path('non_ascii.mustache')
self.assertRaises(UnicodeDecodeError, loader.read, path)
actual = loader.read(path, encoding='utf-8')
self.assertString(actual, 'non-ascii: é')
示例4: test_read__encoding__argument
# 需要导入模块: from pystache.loader import Loader [as 别名]
# 或者: from pystache.loader.Loader import read [as 别名]
def test_read__encoding__argument(self):
"""
Test read(): encoding argument respected.
"""
reader = Loader()
path = self._get_path("non_ascii.mustache")
self.assertRaises(UnicodeDecodeError, reader.read, path)
actual = reader.read(path, encoding="utf-8")
self.assertString(actual, u"non-ascii: é")
示例5: test_read__file_encoding__attribute
# 需要导入模块: from pystache.loader import Loader [as 别名]
# 或者: from pystache.loader.Loader import read [as 别名]
def test_read__file_encoding__attribute(self):
"""
Test read(): file_encoding attribute respected.
"""
loader = Loader()
path = self._get_path('non_ascii.mustache')
self.assertRaises(UnicodeDecodeError, loader.read, path)
loader.file_encoding = 'utf-8'
actual = loader.read(path)
self.assertString(actual, 'non-ascii: é')