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


Python absl.logging方法代码示例

本文整理汇总了Python中absl.logging方法的典型用法代码示例。如果您正苦于以下问题:Python absl.logging方法的具体用法?Python absl.logging怎么用?Python absl.logging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在absl的用法示例。


在下文中一共展示了absl.logging方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_load_constants

# 需要导入模块: import absl [as 别名]
# 或者: from absl import logging [as 别名]
def test_load_constants(self, mock_info_logging):
    test_client = _TestClientAPI()
    test_manager = gng_impl._Manager(
        self._valid_default_config, self._constants, None, False,
        storage_api=test_client,
    )
    test_manager._constants['test'].value = 'valid'
    test_manager._constants['other'].value = 'OVERRIDDEN'
    test_manager._constants['KeyError'] = app_constants.Constant(
        'KeyError', 'This constant is not stored and raises a KeyError', '')

    test_client.insert_blob(
        test_manager._config.constants_storage_path,
        {'test': '', 'other': 'other valid'},
        bucket_name=test_manager._config.bucket,
    )

    test_manager.load_constants_from_storage()
    # Test the default value is used when the loaded value is invalid.
    self.assertEqual(test_manager._constants['test'].value, 'valid')
    # Test loading a valid value overrides the original.
    self.assertEqual(test_manager._constants['other'].value, 'other valid')
    # Test that the 'KeyError' constant calls logging.info.
    self.assertEqual(mock_info_logging.call_count, 1) 
开发者ID:google,项目名称:loaner,代码行数:26,代码来源:gng_impl_test.py

示例2: test_move_to_shelf

# 需要导入模块: import absl [as 别名]
# 或者: from absl import logging [as 别名]
def test_move_to_shelf(self, mock_user, mock_call_count):
    self.enroll_test_device(loanertest.TEST_DIR_DEVICE_DEFAULT)
    self.test_device.assigned_user = mock_user
    with mock.patch.object(
        self.test_device, '_loan_return') as mock_loan_return:
      self.assertFalse(self.test_device.is_on_shelf)
      with mock.patch.object(logging, 'info', autospec=True) as mock_logging:
        now = datetime.datetime(year=2017, month=1, day=1)
        with freezegun.freeze_time(now):
          self.test_device.move_to_shelf(
              shelf=self.shelf, user_email=loanertest.USER_EMAIL)
          self.assertEqual(mock_loan_return.call_count, mock_call_count)
          self.assertTrue(self.test_device.is_on_shelf)
          self.assertEqual(mock_logging.call_count, 1)
          self.assertEqual(now, self.test_device.last_known_healthy) 
开发者ID:google,项目名称:loaner,代码行数:17,代码来源:device_model_test.py

示例3: test_disassociate_tag__not_associated

# 需要导入模块: import absl [as 别名]
# 或者: from absl import logging [as 别名]
def test_disassociate_tag__not_associated(self):
    with mock.patch.object(logging, 'warn', autospec=True) as mock_logging:
      self.device1.disassociate_tag(
          user_email=loanertest.USER_EMAIL,
          tag_name=self.tag2_data.tag.name)
      self.assertTrue(mock_logging.called) 
开发者ID:google,项目名称:loaner,代码行数:8,代码来源:device_model_test.py

示例4: assertLogs

# 需要导入模块: import absl [as 别名]
# 或者: from absl import logging [as 别名]
def assertLogs(self, text, level="info"):
    with absltest.mock.patch.object(logging, level) as mock_log:
      yield
      concat_logs = ""
      for log_call in mock_log.call_args_list:
        args = log_call[0]
        base, args = args[0], args[1:]
        log_text = base % tuple(args)
        concat_logs += " " + log_text
      self.assertIn(text, concat_logs) 
开发者ID:tensorflow,项目名称:datasets,代码行数:12,代码来源:test_case.py

示例5: test_problematic_relation_name

# 需要导入模块: import absl [as 别名]
# 或者: from absl import logging [as 别名]
def test_problematic_relation_name(self):
    with mock.patch.object(logging, 'warn') as mocked_log:
      self.context.declare_relation('follow', 'place_t', 'place_t')
      self.context.declare_relation('tf', 'place_t', 'place_t')
      mocked_log.assert_called() 
开发者ID:google-research,项目名称:language,代码行数:7,代码来源:nql_test.py

示例6: format

# 需要导入模块: import absl [as 别名]
# 或者: from absl import logging [as 别名]
def format(self, record):
        fmt = self._formatters.get(record.levelname) or self._formatters.get("_")
        if fmt:
            return fmt.format(record)
        else:
            return super(ConsoleLogHandler, self).format(record) 
开发者ID:guildai,项目名称:guildai,代码行数:8,代码来源:log.py

示例7: _preempt_logging_mods

# 需要导入模块: import absl [as 别名]
# 或者: from absl import logging [as 别名]
def _preempt_logging_mods():
    """Preempt known logging mods.

    Some modules modify logging without respecting previous config
    (e.g. absl.logging). This function preempts those changes so that
    our config is applied afterward.
    """
    try:
        import absl.logging as _
    except Exception:
        pass 
开发者ID:guildai,项目名称:guildai,代码行数:13,代码来源:log.py


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