本文整理汇总了Python中distutils.command.upload.urlopen方法的典型用法代码示例。如果您正苦于以下问题:Python upload.urlopen方法的具体用法?Python upload.urlopen怎么用?Python upload.urlopen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.command.upload
的用法示例。
在下文中一共展示了upload.urlopen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wrong_exception_order
# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import urlopen [as 别名]
def test_wrong_exception_order(self):
tmp = self.mkdtemp()
path = os.path.join(tmp, 'xxx')
self.write_file(path)
dist_files = [('xxx', '2.6', path)] # command, pyversion, filename
self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
pkg_dir, dist = self.create_dist(dist_files=dist_files)
tests = [
(OSError('oserror'), 'oserror', OSError),
(HTTPError('url', 400, 'httperror', {}, None),
'Upload failed (400): httperror', DistutilsError),
]
for exception, expected, raised_exception in tests:
with self.subTest(exception=type(exception).__name__):
with mock.patch('distutils.command.upload.urlopen',
new=mock.Mock(side_effect=exception)):
with self.assertRaises(raised_exception):
cmd = upload(dist)
cmd.ensure_finalized()
cmd.run()
results = self.get_logs(ERROR)
self.assertIn(expected, results[-1])
self.clear_logs()
示例2: setUp
# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import urlopen [as 别名]
def setUp(self):
super(uploadTestCase, self).setUp()
self.old_open = upload_mod.urlopen
upload_mod.urlopen = self._urlopen
self.last_open = None
self.next_msg = None
self.next_code = None
示例3: tearDown
# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import urlopen [as 别名]
def tearDown(self):
upload_mod.urlopen = self.old_open
super(uploadTestCase, self).tearDown()
示例4: setUp
# 需要导入模块: from distutils.command import upload [as 别名]
# 或者: from distutils.command.upload import urlopen [as 别名]
def setUp(self):
super(uploadTestCase, self).setUp()
self.old_open = upload_mod.urlopen
upload_mod.urlopen = self._urlopen
self.last_open = None