当前位置: 首页>>代码示例>>Python>>正文


Python upload.urlopen方法代码示例

本文整理汇总了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() 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:26,代码来源:test_upload.py

示例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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_upload.py

示例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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_upload.py

示例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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_upload.py


注:本文中的distutils.command.upload.urlopen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。