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


Python FakeLogger.all_log_lines方法代码示例

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


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

示例1: test_two_realms_and_change_a_default

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
    def test_two_realms_and_change_a_default(self):
        fname = 'container-sync-realms.conf'
        fcontents = '''
[DEFAULT]
mtime_check_interval = 60

[US]
key = 9ff3b71c849749dbaec4ccdd3cbab62b
cluster_dfw1 = http://dfw1.host/v1/

[UK]
key = e9569809dc8b4951accc1487aa788012
key2 = f6351bd1cc36413baa43f7ba1b45e51d
cluster_lon3 = http://lon3.host/v1/
'''
        with temptree([fname], [fcontents]) as tempdir:
            logger = FakeLogger()
            fpath = os.path.join(tempdir, fname)
            csr = ContainerSyncRealms(fpath, logger)
            self.assertEqual(logger.all_log_lines(), {})
            self.assertEqual(csr.mtime_check_interval, 60)
            self.assertEqual(sorted(csr.realms()), ['UK', 'US'])
            self.assertEqual(csr.key('US'), '9ff3b71c849749dbaec4ccdd3cbab62b')
            self.assertEqual(csr.key2('US'), None)
            self.assertEqual(csr.clusters('US'), ['DFW1'])
            self.assertEqual(
                csr.endpoint('US', 'DFW1'), 'http://dfw1.host/v1/')
            self.assertEqual(csr.key('UK'), 'e9569809dc8b4951accc1487aa788012')
            self.assertEqual(
                csr.key2('UK'), 'f6351bd1cc36413baa43f7ba1b45e51d')
            self.assertEqual(csr.clusters('UK'), ['LON3'])
            self.assertEqual(
                csr.endpoint('UK', 'LON3'), 'http://lon3.host/v1/')
开发者ID:Joyezhu,项目名称:swift,代码行数:35,代码来源:test_container_sync_realms.py

示例2: test_empty

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
 def test_empty(self):
     fname = 'container-sync-realms.conf'
     fcontents = ''
     with temptree([fname], [fcontents]) as tempdir:
         logger = FakeLogger()
         fpath = os.path.join(tempdir, fname)
         csr = ContainerSyncRealms(fpath, logger)
         self.assertEqual(logger.all_log_lines(), {})
         self.assertEqual(csr.mtime_check_interval, 300)
         self.assertEqual(csr.realms(), [])
开发者ID:Joyezhu,项目名称:swift,代码行数:12,代码来源:test_container_sync_realms.py

示例3: test_no_file_there

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
 def test_no_file_there(self):
     unique = uuid.uuid4().hex
     logger = FakeLogger()
     csr = ContainerSyncRealms(unique, logger)
     self.assertEqual(
         logger.all_log_lines(),
         {'debug': [
             "Could not load '%s': [Errno 2] No such file or directory: "
             "'%s'" % (unique, unique)]})
     self.assertEqual(csr.mtime_check_interval, 300)
     self.assertEqual(csr.realms(), [])
开发者ID:Joyezhu,项目名称:swift,代码行数:13,代码来源:test_container_sync_realms.py

示例4: test_error_parsing

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
 def test_error_parsing(self):
     fname = 'container-sync-realms.conf'
     fcontents = 'invalid'
     with temptree([fname], [fcontents]) as tempdir:
         logger = FakeLogger()
         fpath = os.path.join(tempdir, fname)
         csr = ContainerSyncRealms(fpath, logger)
         self.assertEqual(
             logger.all_log_lines(),
             {'error': [
                 "Could not load '%s': File contains no section headers.\n"
                 "file: %s, line: 1\n"
                 "'invalid'" % (fpath, fpath)]})
         self.assertEqual(csr.mtime_check_interval, 300)
         self.assertEqual(csr.realms(), [])
开发者ID:Joyezhu,项目名称:swift,代码行数:17,代码来源:test_container_sync_realms.py

示例5: test_bad_mtime_check_interval

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
    def test_bad_mtime_check_interval(self):
        fname = 'container-sync-realms.conf'
        fcontents = '''
[DEFAULT]
mtime_check_interval = invalid
'''
        with temptree([fname], [fcontents]) as tempdir:
            logger = FakeLogger()
            fpath = os.path.join(tempdir, fname)
            csr = ContainerSyncRealms(fpath, logger)
            self.assertEqual(
                logger.all_log_lines(),
                {'error': [
                    "Error in '%s' with mtime_check_interval: invalid literal "
                    "for int() with base 10: 'invalid'" % fpath]})
            self.assertEqual(csr.mtime_check_interval, 300)
开发者ID:Joyezhu,项目名称:swift,代码行数:18,代码来源:test_container_sync_realms.py

示例6: test_empty_realm

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
    def test_empty_realm(self):
        fname = 'container-sync-realms.conf'
        fcontents = '''
[US]
'''
        with temptree([fname], [fcontents]) as tempdir:
            logger = FakeLogger()
            fpath = os.path.join(tempdir, fname)
            csr = ContainerSyncRealms(fpath, logger)
            self.assertEqual(logger.all_log_lines(), {})
            self.assertEqual(csr.mtime_check_interval, 300)
            self.assertEqual(csr.realms(), ['US'])
            self.assertEqual(csr.key('US'), None)
            self.assertEqual(csr.key2('US'), None)
            self.assertEqual(csr.clusters('US'), [])
            self.assertEqual(csr.endpoint('US', 'JUST_TESTING'), None)
开发者ID:Joyezhu,项目名称:swift,代码行数:18,代码来源:test_container_sync_realms.py

示例7: test_os_error

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
 def test_os_error(self):
     fname = 'container-sync-realms.conf'
     fcontents = ''
     with temptree([fname], [fcontents]) as tempdir:
         logger = FakeLogger()
         fpath = os.path.join(tempdir, fname)
         os.chmod(tempdir, 0)
         csr = ContainerSyncRealms(fpath, logger)
         try:
             self.assertEqual(
                 logger.all_log_lines(),
                 {'error': [
                     "Could not load '%s': [Errno 13] Permission denied: "
                     "'%s'" % (fpath, fpath)]})
             self.assertEqual(csr.mtime_check_interval, 300)
             self.assertEqual(csr.realms(), [])
         finally:
             os.chmod(tempdir, 0700)
开发者ID:Joyezhu,项目名称:swift,代码行数:20,代码来源:test_container_sync_realms.py

示例8: test_one_realm

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
    def test_one_realm(self):
        fname = 'container-sync-realms.conf'
        fcontents = '''
[US]
key = 9ff3b71c849749dbaec4ccdd3cbab62b
cluster_dfw1 = http://dfw1.host/v1/
'''
        with temptree([fname], [fcontents]) as tempdir:
            logger = FakeLogger()
            fpath = os.path.join(tempdir, fname)
            csr = ContainerSyncRealms(fpath, logger)
            self.assertEqual(logger.all_log_lines(), {})
            self.assertEqual(csr.mtime_check_interval, 300)
            self.assertEqual(csr.realms(), ['US'])
            self.assertEqual(csr.key('US'), '9ff3b71c849749dbaec4ccdd3cbab62b')
            self.assertEqual(csr.key2('US'), None)
            self.assertEqual(csr.clusters('US'), ['DFW1'])
            self.assertEqual(
                csr.endpoint('US', 'DFW1'), 'http://dfw1.host/v1/')
开发者ID:Joyezhu,项目名称:swift,代码行数:21,代码来源:test_container_sync_realms.py

示例9: test_os_error

# 需要导入模块: from test.unit import FakeLogger [as 别名]
# 或者: from test.unit.FakeLogger import all_log_lines [as 别名]
    def test_os_error(self):
        fname = 'container-sync-realms.conf'
        fcontents = ''
        with temptree([fname], [fcontents]) as tempdir:
            logger = FakeLogger()
            fpath = os.path.join(tempdir, fname)

            def _mock_getmtime(path):
                raise OSError(errno.EACCES,
                              os.strerror(errno.EACCES) +
                              ": '%s'" % (fpath))
            with patch('os.path.getmtime', _mock_getmtime):
                csr = ContainerSyncRealms(fpath, logger)

            self.assertEqual(
                logger.all_log_lines(),
                {'error': [
                    "Could not load '%s': [Errno 13] Permission denied: "
                    "'%s'" % (fpath, fpath)]})
            self.assertEqual(csr.mtime_check_interval, 300)
            self.assertEqual(csr.realms(), [])
开发者ID:AfonsoFGarcia,项目名称:swift,代码行数:23,代码来源:test_container_sync_realms.py


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