本文整理匯總了Python中wpull.application.builder.Builder.run方法的典型用法代碼示例。如果您正苦於以下問題:Python Builder.run方法的具體用法?Python Builder.run怎麽用?Python Builder.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wpull.application.builder.Builder
的用法示例。
在下文中一共展示了Builder.run方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_file_continue
# 需要導入模塊: from wpull.application.builder import Builder [as 別名]
# 或者: from wpull.application.builder.Builder import run [as 別名]
def test_file_continue(self):
arg_parser = AppArgumentParser()
args = arg_parser.parse_args([self.get_url("/static/my_file.txt"), "--continue", "--debug"])
filename = os.path.join(self.temp_dir.name, "my_file.txt")
with open(filename, "wb") as out_file:
out_file.write(b"START")
app = Builder(args, unit_test=True).build()
exit_code = yield from app.run()
self.assertEqual(0, exit_code)
with open(filename, "rb") as in_file:
data = in_file.read()
self.assertEqual("54388a281352fdb2cfa66009ac0e35dd8916af7c", hashlib.sha1(data).hexdigest())
示例2: test_file_continue
# 需要導入模塊: from wpull.application.builder import Builder [as 別名]
# 或者: from wpull.application.builder.Builder import run [as 別名]
def test_file_continue(self):
arg_parser = AppArgumentParser()
args = arg_parser.parse_args([self.get_url('/example (copy).txt'),
'--continue', '--debug'])
filename = os.path.join(self.temp_dir.name, 'example (copy).txt')
with open(filename, 'wb') as out_file:
out_file.write(b'The')
app = Builder(args, unit_test=True).build()
exit_code = yield from app.run()
self.assertEqual(0, exit_code)
with open(filename, 'rb') as in_file:
data = in_file.read()
self.assertEqual(
'The real treasure is in Smaug’s heart 💗.\n'
.encode('utf-8'),
data
)