本文整理汇总了Python中distutils.log.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Python log.ERROR属性的具体用法?Python log.ERROR怎么用?Python log.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类distutils.log
的用法示例。
在下文中一共展示了log.ERROR属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wrong_exception_order
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [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: run_tests
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [as 别名]
def run_tests(self):
# Purge modules under test from sys.modules. The test loader will
# re-import them from the build location. Required when 2to3 is used
# with namespace packages.
if six.PY3 and getattr(self.distribution, 'use_2to3', False):
module = self.test_suite.split('.')[0]
if module in _namespace_packages:
del_modules = []
if module in sys.modules:
del_modules.append(module)
module += '.'
for name in sys.modules:
if name.startswith(module):
del_modules.append(name)
list(map(sys.modules.__delitem__, del_modules))
exit_kwarg = {} if sys.version_info < (2, 7) else {"exit": False}
test = unittest_main(
None, None, self._argv,
testLoader=self._resolve_as_ep(self.test_loader),
testRunner=self._resolve_as_ep(self.test_runner),
**exit_kwarg
)
if not test.result.wasSuccessful():
msg = 'Test failed: %s' % test.result
self.announce(msg, log.ERROR)
raise DistutilsError(msg)
示例3: run_tests
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [as 别名]
def run_tests(self):
# Purge modules under test from sys.modules. The test loader will
# re-import them from the build location. Required when 2to3 is used
# with namespace packages.
if six.PY3 and getattr(self.distribution, 'use_2to3', False):
module = self.test_suite.split('.')[0]
if module in _namespace_packages:
del_modules = []
if module in sys.modules:
del_modules.append(module)
module += '.'
for name in sys.modules:
if name.startswith(module):
del_modules.append(name)
list(map(sys.modules.__delitem__, del_modules))
test = unittest.main(
None, None, self._argv,
testLoader=self._resolve_as_ep(self.test_loader),
testRunner=self._resolve_as_ep(self.test_runner),
exit=False,
)
if not test.result.wasSuccessful():
msg = 'Test failed: %s' % test.result
self.announce(msg, log.ERROR)
raise DistutilsError(msg)
示例4: _log
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [as 别名]
def _log(self, level, msg, args):
if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
raise ValueError('%s wrong log level' % str(level))
self.logs.append((level, msg, args))
示例5: run
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [as 别名]
def run(self):
msg = (
"The upload command has been removed, use twine to upload "
+ "instead (https://pypi.org/p/twine)"
)
self.announce("ERROR: " + msg, log.ERROR)
raise RemovedCommandError(msg)
示例6: run
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [as 别名]
def run(self):
msg = (
"The register command has been removed, use twine to upload "
+ "instead (https://pypi.org/p/twine)"
)
self.announce("ERROR: " + msg, log.ERROR)
raise RemovedCommandError(msg)
示例7: _log
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [as 别名]
def _log(self, level, msg, args):
if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
raise ValueError('%s wrong log level' % str(level))
if not isinstance(msg, str):
raise TypeError("msg should be str, not '%.200s'"
% (type(msg).__name__))
self.logs.append((level, msg, args))
示例8: run_tests
# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import ERROR [as 别名]
def run_tests(self):
# Purge modules under test from sys.modules. The test loader will
# re-import them from the build location. Required when 2to3 is used
# with namespace packages.
if not six.PY2 and getattr(self.distribution, 'use_2to3', False):
module = self.test_suite.split('.')[0]
if module in _namespace_packages:
del_modules = []
if module in sys.modules:
del_modules.append(module)
module += '.'
for name in sys.modules:
if name.startswith(module):
del_modules.append(name)
list(map(sys.modules.__delitem__, del_modules))
test = unittest.main(
None, None, self._argv,
testLoader=self._resolve_as_ep(self.test_loader),
testRunner=self._resolve_as_ep(self.test_runner),
exit=False,
)
if not test.result.wasSuccessful():
msg = 'Test failed: %s' % test.result
self.announce(msg, log.ERROR)
raise DistutilsError(msg)