我们从Python开源项目中,提取了以下46个代码示例,用于说明如何使用distutils.log.WARN。
def test_metadata_check_option(self): # testing the `medata-check` option dist, cmd = self.get_cmd(metadata={}) # this should raise some warnings ! # with the `check` subcommand cmd.ensure_finalized() cmd.run() warnings = [msg for msg in self.get_logs(WARN) if msg.startswith('warning: check:')] self.assertEqual(len(warnings), 2) # trying with a complete set of metadata self.clear_logs() dist, cmd = self.get_cmd() cmd.ensure_finalized() cmd.metadata_check = 0 cmd.run() warnings = [msg for msg in self.get_logs(WARN) if msg.startswith('warning: check:')] self.assertEqual(len(warnings), 0)
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))
def _check_template(self, content): dist, cmd = self.get_cmd() os.chdir(self.tmp_dir) self.write_file('MANIFEST.in', content) cmd.ensure_finalized() cmd.filelist = FileList() cmd.read_template() warnings = self.get_logs(WARN) self.assertEqual(len(warnings), 1)
def assertNoWarnings(self): self.assertEqual(self.get_logs(WARN), []) self.clear_logs()
def assertWarnings(self): self.assertGreater(len(self.get_logs(WARN)), 0) self.clear_logs()
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))
def _log(self, level, msg, args): if level not in (log.DEBUG, log.INFO, log.WARN, log.ERROR, log.FATAL): raise ValueError('%s wrong log level' % str(level)) self.logs.append((level, msg, args))
def assertNoWarnings(self): assert self.get_logs(log.WARN) == [] self.clear_logs()
def assertWarnings(self): assert len(self.get_logs(log.WARN)) > 0 self.clear_logs()