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


Python LogFileMark.readline方法代码示例

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


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

示例1: test_archive_lock_used

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_archive_lock_used(self):
     # Test that locking the maildir when adding works as a failure here
     # could mean we lose mail.
     lock_file = os.path.join(
         config.LOCK_DIR, '{0}-maildir.lock'.format(
             self._mlist.fqdn_listname))
     with Lock(lock_file):
         # Acquire the archiver lock, then make sure the archiver logs the
         # fact that it could not acquire the lock.
         archive_thread = threading.Thread(
             target=Prototype.archive_message,
             args=(self._mlist, self._msg))
         mark = LogFileMark('mailman.error')
         archive_thread.run()
         # Test that the archiver output the correct error.
         line = mark.readline()
         # XXX 2012-03-15 BAW: we really should remove timestamp prefixes
         # from the loggers when under test.
         self.assertTrue(line.endswith(
             'Unable to acquire prototype archiver lock for {0}, '
             'discarding: {1}\n'.format(
                 self._mlist.fqdn_listname,
                 self._msg.get('message-id'))))
     # Check that the message didn't get archived.
     created_files = self._find(config.ARCHIVE_DIR)
     self.assertEqual(self._expected_dir_structure, created_files)
开发者ID:aregee,项目名称:Mailman,代码行数:28,代码来源:test_prototype.py

示例2: test_no_detectable_bounce_addresses

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
    def test_no_detectable_bounce_addresses(self):
        # A bounce message was received, but no addresses could be detected.
        # A message will be logged in the bounce log though, and the message
        # can be forwarded to someone who can do something about it.
        self._mlist.forward_unrecognized_bounces_to = (
            UnrecognizedBounceDisposition.site_owner)
        bogus = message_from_string("""\
From: [email protected]
To: [email protected]
Message-Id: <third>

""")
        self._bounceq.enqueue(bogus, self._msgdata)
        mark = LogFileMark('mailman.bounce')
        self._runner.run()
        self.assertEqual(len(get_queue_messages('bounces')), 0)
        events = list(self._processor.events)
        self.assertEqual(len(events), 0)
        line = mark.readline()
        self.assertEqual(
            line[-51:-1],
            'Bounce message w/no discernable addresses: <third>')
        # Here's the forwarded message to the site owners.
        forwards = get_queue_messages('virgin')
        self.assertEqual(len(forwards), 1)
        self.assertEqual(forwards[0].msg['to'], '[email protected]')
开发者ID:aditigupta96,项目名称:mailman3,代码行数:28,代码来源:test_bounce.py

示例3: test_bad_configuration_line

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_bad_configuration_line(self):
     # Take a mark on the error log file.
     mark = LogFileMark('mailman.error')
     # A bad value in [antispam]header_checks should just get ignored, but
     # with an error message logged.
     chain = config.chains['header-match']
     # The links are created dynamically; the rule names will all start
     # with the same prefix, but have a variable suffix.  The actions will
     # all be to jump to the named chain.  Do these checks now, while we
     # collect other useful information.
     post_checks = []
     saw_any_rule = False
     for link in chain.get_links(self._mlist, Message(), {}):
         if link.rule.name == 'any':
             saw_any_rule = True
             self.assertEqual(link.action, LinkAction.jump)
         elif saw_any_rule:
             raise AssertionError("'any' rule was not last")
         else:
             self.assertEqual(link.rule.name[:13], 'header-match-')
             self.assertEqual(link.action, LinkAction.defer)
             post_checks.append((link.rule.header, link.rule.pattern))
     self.assertListEqual(post_checks, [
         ('Foo', 'foo'),
         ('Bar', 'bar'),
         ])
     # Check the error log.
     self.assertEqual(mark.readline()[-77:-1],
                      'Configuration error: [antispam]header_checks '
                      'contains bogus line: A-bad-line')
开发者ID:aregee,项目名称:Mailman,代码行数:32,代码来源:test_headers.py

示例4: test_connect_with_socket_failure

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_connect_with_socket_failure(self, class_mock):
     self._nntpq.enqueue(self._msg, {}, listname='[email protected]')
     mark = LogFileMark('mailman.error')
     self._runner.run()
     log_message = mark.readline()[:-1]
     self.assertTrue(log_message.endswith(
         'NNTP socket error for [email protected]'))
开发者ID:aregee,项目名称:Mailman,代码行数:9,代码来源:test_nntp.py

示例5: test_discarding_pipeline

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_discarding_pipeline(self):
     # If a handler in the pipeline raises DiscardMessage, the message will
     # be thrown away, but with a log message.
     mark = LogFileMark('mailman.vette')
     process(self._mlist, self._msg, {}, 'test-discarding')
     line = mark.readline()[:-1]
     self.assertTrue(line.endswith(
         '<ant> discarded by "test-discarding" pipeline handler '
         '"discarding": by test handler'))
开发者ID:aditigupta96,项目名称:mailman3,代码行数:11,代码来源:test_pipelines.py

示例6: test_header_matches_invalid_re

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_header_matches_invalid_re(self):
     # Check that an invalid regular expression pattern is skipped.
     self._pckdict['header_filter_rules'] = [
         ('SomeHeaderName: *invalid-re', 3, False),
         ]
     error_log = LogFileMark('mailman.error')
     self._import()
     self.assertListEqual(self._mlist.header_matches, [])
     self.assertIn('Skipping header_filter rule because of an invalid '
                   'regular expression', error_log.readline())
开发者ID:aswinpj,项目名称:Mailman,代码行数:12,代码来源:test_import.py

示例7: test_header_matches_header_only

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_header_matches_header_only(self):
     # Check that an empty pattern is skipped.
     self._pckdict['header_filter_rules'] = [
         ('SomeHeaderName', 3, False),
         ]
     error_log = LogFileMark('mailman.error')
     self._import()
     self.assertListEqual(self._mlist.header_matches, [])
     self.assertIn('Unsupported header_filter_rules pattern',
                   error_log.readline())
开发者ID:aswinpj,项目名称:Mailman,代码行数:12,代码来源:test_import.py

示例8: test_header_matches_anything

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_header_matches_anything(self):
     # Check that a wild card header pattern is skipped.
     self._pckdict['header_filter_rules'] = [
         ('.*', 7, False),
         ]
     error_log = LogFileMark('mailman.error')
     self._import()
     self.assertListEqual(self._mlist.header_matches, [])
     self.assertIn('Unsupported header_filter_rules pattern',
                   error_log.readline())
开发者ID:aswinpj,项目名称:Mailman,代码行数:12,代码来源:test_import.py

示例9: test_maybe_forward_discard

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_maybe_forward_discard(self):
     # When forward_unrecognized_bounces_to is set to discard, no bounce
     # messages are forwarded.
     self._mlist.forward_unrecognized_bounces_to = (
         UnrecognizedBounceDisposition.discard)
     # The only artifact of this call is a log file entry.
     mark = LogFileMark('mailman.bounce')
     maybe_forward(self._mlist, self._msg)
     get_queue_messages('virgin', expected_count=0)
     line = mark.readline()
     self.assertEqual(
         line[-40:-1],
         'Discarding unrecognized bounce: <first>')
开发者ID:aswinpj,项目名称:Mailman,代码行数:15,代码来源:test_bounces.py

示例10: test_rejecting_pipeline

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_rejecting_pipeline(self):
     # If a handler in the pipeline raises DiscardMessage, the message will
     # be thrown away, but with a log message.
     mark = LogFileMark('mailman.vette')
     process(self._mlist, self._msg, {}, 'test-rejecting')
     line = mark.readline()[:-1]
     self.assertTrue(line.endswith(
         '<ant> rejected by "test-rejecting" pipeline handler '
         '"rejecting": by test handler'))
     # In the rejection case, the original message will also be in the
     # virgin queue.
     items = get_queue_messages('virgin', expected_count=1)
     self.assertEqual(str(items[0].msg['subject']), 'a test')
开发者ID:aswinpj,项目名称:Mailman,代码行数:15,代码来源:test_pipelines.py

示例11: test_header_matches_duplicate

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_header_matches_duplicate(self):
     # Check that duplicate patterns don't cause tracebacks.
     self._pckdict['header_filter_rules'] = [
         ('SomeHeaderName: test-pattern', 3, False),
         ('SomeHeaderName: test-pattern', 2, False),
         ]
     error_log = LogFileMark('mailman.error')
     self._import()
     self.assertListEqual(
         [(hm.header, hm.pattern, hm.chain)
          for hm in self._mlist.header_matches],
         [('someheadername', 'test-pattern', 'discard')]
         )
     self.assertIn('Skipping duplicate header_filter rule',
                   error_log.readline())
开发者ID:aswinpj,项目名称:Mailman,代码行数:17,代码来源:test_import.py

示例12: test_error_with_numeric_port

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_error_with_numeric_port(self):
     # Test the code path where a socket.error is raised in the delivery
     # function, and the MTA port is set to zero.  The only real effect of
     # that is a log message.  Start by opening the error log and reading
     # the current file position.
     mark = LogFileMark('mailman.error')
     self._outq.enqueue(self._msg, {}, listid='test.example.com')
     with configuration('mta', smtp_port=2112):
         self._runner.run()
     line = mark.readline()
     # The log line will contain a variable timestamp, the PID, and a
     # trailing newline.  Ignore these.
     self.assertEqual(
         line[-53:-1],
         'Cannot connect to SMTP server localhost on port 2112')
开发者ID:aswinpj,项目名称:Mailman,代码行数:17,代码来源:test_outgoing.py

示例13: test_get_moderator_approval_log_on_hold

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_get_moderator_approval_log_on_hold(self):
     # When the subscription is held for moderator approval, a message is
     # logged.
     mark = LogFileMark('mailman.subscribe')
     self._mlist.subscription_policy = SubscriptionPolicy.moderate
     anne = self._user_manager.create_address(self._anne)
     workflow = SubscriptionWorkflow(self._mlist, anne,
                                     pre_verified=True,
                                     pre_confirmed=True)
     # Consume the entire state machine.
     list(workflow)
     self.assertIn(
        '[email protected]: held subscription request from [email protected]',
        mark.readline()
        )
开发者ID:P-EB,项目名称:mailman3-core,代码行数:17,代码来源:test_subscriptions.py

示例14: test_header_matches_unsupported_action

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_header_matches_unsupported_action(self):
     # Check that unsupported actions are skipped.
     for action_num in (1, 4, 5):
         self._pckdict['header_filter_rules'] = [
             ('HeaderName: test-re', action_num, False),
             ]
         error_log = LogFileMark('mailman.error')
         self._import()
         self.assertListEqual(self._mlist.header_matches, [])
         self.assertIn('Unsupported header_filter_rules action',
                       error_log.readline())
         # Avoid a useless warning.
         for member in self._mlist.members.members:
             member.unsubscribe()
         for member in self._mlist.owners.members:
             member.unsubscribe()
开发者ID:aswinpj,项目名称:Mailman,代码行数:18,代码来源:test_import.py

示例15: test_connect_with_other_failure

# 需要导入模块: from mailman.testing.helpers import LogFileMark [as 别名]
# 或者: from mailman.testing.helpers.LogFileMark import readline [as 别名]
 def test_connect_with_other_failure(self, class_mock):
     # In this failure mode, the message stays queued, so we can only run
     # the nntp runner once.
     def once(runner):
         # I.e. stop immediately, since the queue will not be empty.
         return True
     runner = make_testable_runner(nntp.NNTPRunner, 'nntp', predicate=once)
     self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
     mark = LogFileMark('mailman.error')
     runner.run()
     log_message = mark.readline()[:-1]
     self.assertTrue(log_message.endswith(
         'NNTP unexpected exception for [email protected]'))
     items = get_queue_messages('nntp', expected_count=1)
     self.assertEqual(items[0].msgdata['listid'], 'test.example.com')
     self.assertEqual(items[0].msg['subject'], 'A newsgroup posting')
开发者ID:aswinpj,项目名称:Mailman,代码行数:18,代码来源:test_nntp.py


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