summaryrefslogtreecommitdiff
path: root/mailman/testing
diff options
context:
space:
mode:
authorBarry Warsaw2009-01-16 21:04:21 -0500
committerBarry Warsaw2009-01-16 21:04:21 -0500
commitae3d0cc316b826b8325507d960ccf84da601c3b0 (patch)
tree3485e2ca463c2131a0ffb1693bc60d569cc9d8b7 /mailman/testing
parenta3f7d07c62b2f7d6ac9d0b700883826c2838db60 (diff)
downloadmailman-ae3d0cc316b826b8325507d960ccf84da601c3b0.tar.gz
mailman-ae3d0cc316b826b8325507d960ccf84da601c3b0.tar.zst
mailman-ae3d0cc316b826b8325507d960ccf84da601c3b0.zip
Several important cleanups.
* Turn on absolute_import and unicode_literals everywhere, and deal with the aftermath. * Use 'except X as Y' everywhere. * Make the module prologues much more consistent. * Use '{}'.format() consistently, except for logger interface. * Because of the problems with calling ** args with unicode keywords, hide calls to Template.substitute() behind an API.
Diffstat (limited to 'mailman/testing')
-rw-r--r--mailman/testing/helpers.py2
-rw-r--r--mailman/testing/layers.py10
-rw-r--r--mailman/testing/mta.py2
-rw-r--r--mailman/testing/smtplistener.py10
4 files changed, 19 insertions, 5 deletions
diff --git a/mailman/testing/helpers.py b/mailman/testing/helpers.py
index 9b5252b71..f92c5f012 100644
--- a/mailman/testing/helpers.py
+++ b/mailman/testing/helpers.py
@@ -17,6 +17,8 @@
"""Various test helpers."""
+from __future__ import absolute_import, unicode_literals
+
__metaclass__ = type
__all__ = [
'TestableMaster',
diff --git a/mailman/testing/layers.py b/mailman/testing/layers.py
index f3a4266fd..19300ba1e 100644
--- a/mailman/testing/layers.py
+++ b/mailman/testing/layers.py
@@ -17,6 +17,8 @@
"""Mailman test layers."""
+from __future__ import absolute_import, unicode_literals
+
__metaclass__ = type
__all__ = [
'ConfigLayer',
@@ -31,7 +33,6 @@ import logging
import tempfile
from pkg_resources import resource_string
-from string import Template
from textwrap import dedent
from mailman.config import config
@@ -39,6 +40,7 @@ from mailman.core import initialize
from mailman.core.logging import get_handler
from mailman.i18n import _
from mailman.testing.helpers import SMTPServer
+from mailman.utilities.string import expand
NL = '\n'
@@ -105,11 +107,11 @@ class ConfigLayer:
# If stderr debugging is enabled, make sure subprocesses are also
# more verbose.
if cls.stderr:
- test_config += Template(dedent("""
+ test_config += expand(dedent("""
[logging.$name]
propagate: yes
level: debug
- """)).substitute(name=sub_name, path=path)
+ """), dict(name=sub_name, path=path))
# zope.testing sets up logging before we get to our own initialization
# function. This messes with the root logger, so explicitly set it to
# go to stderr.
@@ -170,7 +172,7 @@ class ConfigLayer:
zc.testing package. There should be a better way!
"""
from zope.testing.testrunner.options import parser
- parser.add_option('-e', '--stderr',
+ parser.add_option(str('-e'), str('--stderr'),
action='callback', callback=cls.handle_stderr,
help=_('Propagate log errors to stderr.'))
diff --git a/mailman/testing/mta.py b/mailman/testing/mta.py
index af1c19223..a10ba3c81 100644
--- a/mailman/testing/mta.py
+++ b/mailman/testing/mta.py
@@ -17,6 +17,8 @@
"""Fake MTA for testing purposes."""
+from __future__ import absolute_import, unicode_literals
+
__metaclass__ = type
__all__ = [
'FakeMTA',
diff --git a/mailman/testing/smtplistener.py b/mailman/testing/smtplistener.py
index f7f584f92..2094e20de 100644
--- a/mailman/testing/smtplistener.py
+++ b/mailman/testing/smtplistener.py
@@ -17,6 +17,14 @@
"""A test SMTP listener."""
+from __future__ import absolute_import, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'Server',
+ ]
+
+
import smtpd
import socket
import logging
@@ -71,7 +79,7 @@ class Server(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
"""Process a message by adding it to the mailbox."""
message = message_from_string(data)
- message['X-Peer'] = '%s:%s' % peer
+ message['X-Peer'] = '{0}:{1}'.format(*peer)
message['X-MailFrom'] = mailfrom
message['X-RcptTo'] = COMMASPACE.join(rcpttos)
log.info('[SMTPServer] processed message: %s',