本文整理匯總了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: é')