本文整理汇总了Python中mapper.Mapper.prepare方法的典型用法代码示例。如果您正苦于以下问题:Python Mapper.prepare方法的具体用法?Python Mapper.prepare怎么用?Python Mapper.prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapper.Mapper
的用法示例。
在下文中一共展示了Mapper.prepare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMapper
# 需要导入模块: from mapper import Mapper [as 别名]
# 或者: from mapper.Mapper import prepare [as 别名]
class TestMapper(object):
used = False
def empty(self, *args, **kw):
self.used = True
def setUp(self):
self.used = False
self.opts = Opts()
self.mapper = Mapper(self.opts)
self.mapper.save_config = self.empty
def parse_opts_test(self):
self.opts.title = 'название 1'.decode('utf-8')
self.mapper.prepare()
assert (self.mapper.config['title'] == u'название 1')
assert self.used
def load_config_test(self):
config = {'title': 'название 2'}
f = NamedTemporaryFile()
json.dump(config, f, encoding='utf-8')
f.flush()
self.opts.config = f.name
self.mapper.prepare()
assert (self.mapper.config['title'] == u'название 2')
def get_pagesize_test(self):
assert self.mapper.get_page_size('a4') == self.mapper.get_page_size('A4')
x, y = self.mapper.get_page_size('a4')
assert self.mapper.get_page_size('a4', True) == (y, x)
assert self.mapper.get_page_size('a3', False) == (y, x * 2)
def get_coords_test(self):
assert self.mapper.get_coords('235,117.2') == [235., 117.2]