mirror of https://github.com/python/cpython
Whitespace normalization.
This commit is contained in:
parent
2f93e28a19
commit
527e64fd68
|
@ -946,7 +946,7 @@ class Differ:
|
||||||
|
|
||||||
yield "- " + aline
|
yield "- " + aline
|
||||||
if atags:
|
if atags:
|
||||||
yield "? %s%s\n" % ("\t" * common, atags)
|
yield "? %s%s\n" % ("\t" * common, atags)
|
||||||
|
|
||||||
yield "+ " + bline
|
yield "+ " + bline
|
||||||
if btags:
|
if btags:
|
||||||
|
|
|
@ -8,7 +8,7 @@ import base64
|
||||||
from quopri import encodestring as _encodestring
|
from quopri import encodestring as _encodestring
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
def _qencode(s):
|
def _qencode(s):
|
||||||
return _encodestring(s, quotetabs=1)
|
return _encodestring(s, quotetabs=1)
|
||||||
|
@ -26,7 +26,7 @@ def _bencode(s):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def encode_base64(msg):
|
def encode_base64(msg):
|
||||||
"""Encode the message's payload in Base64.
|
"""Encode the message's payload in Base64.
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ def encode_base64(msg):
|
||||||
msg['Content-Transfer-Encoding'] = 'base64'
|
msg['Content-Transfer-Encoding'] = 'base64'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def encode_quopri(msg):
|
def encode_quopri(msg):
|
||||||
"""Encode the message's payload in Quoted-Printable.
|
"""Encode the message's payload in Quoted-Printable.
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ def encode_quopri(msg):
|
||||||
msg['Content-Transfer-Encoding'] = 'quoted-printable'
|
msg['Content-Transfer-Encoding'] = 'quoted-printable'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def encode_7or8bit(msg):
|
def encode_7or8bit(msg):
|
||||||
"""Set the Content-Transfer-Encoding: header to 7bit or 8bit."""
|
"""Set the Content-Transfer-Encoding: header to 7bit or 8bit."""
|
||||||
orig = msg.get_payload()
|
orig = msg.get_payload()
|
||||||
|
@ -64,6 +64,6 @@ def encode_7or8bit(msg):
|
||||||
msg['Content-Transfer-Encoding'] = '7bit'
|
msg['Content-Transfer-Encoding'] = '7bit'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def encode_noop(msg):
|
def encode_noop(msg):
|
||||||
"""Do nothing."""
|
"""Do nothing."""
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MessageError(Exception):
|
class MessageError(Exception):
|
||||||
"""Base class for errors in this module."""
|
"""Base class for errors in this module."""
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ SPACE8 = ' ' * 8
|
||||||
fcre = re.compile(r'^From ', re.MULTILINE)
|
fcre = re.compile(r'^From ', re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Generator:
|
class Generator:
|
||||||
"""Generates output from a Message object tree.
|
"""Generates output from a Message object tree.
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ class Generator:
|
||||||
self._fp.write(s.getvalue())
|
self._fp.write(s.getvalue())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DecodedGenerator(Generator):
|
class DecodedGenerator(Generator):
|
||||||
"""Generator a text representation of a message.
|
"""Generator a text representation of a message.
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ class DecodedGenerator(Generator):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Helper
|
# Helper
|
||||||
def _make_boundary(self, text=None):
|
def _make_boundary(self, text=None):
|
||||||
# Craft a random boundary. If text is given, ensure that the chosen
|
# Craft a random boundary. If text is given, ensure that the chosen
|
||||||
|
|
|
@ -9,7 +9,7 @@ from cStringIO import StringIO
|
||||||
from types import StringType
|
from types import StringType
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def body_line_iterator(msg):
|
def body_line_iterator(msg):
|
||||||
"""Iterate over the parts, returning string payloads line-by-line."""
|
"""Iterate over the parts, returning string payloads line-by-line."""
|
||||||
for subpart in msg.walk():
|
for subpart in msg.walk():
|
||||||
|
@ -19,7 +19,7 @@ def body_line_iterator(msg):
|
||||||
yield line
|
yield line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def typed_subpart_iterator(msg, maintype='text', subtype=None):
|
def typed_subpart_iterator(msg, maintype='text', subtype=None):
|
||||||
"""Iterate over the subparts with a given MIME type.
|
"""Iterate over the subparts with a given MIME type.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import Message
|
import Message
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MIMEBase(Message.Message):
|
class MIMEBase(Message.Message):
|
||||||
"""Base class for MIME specializations."""
|
"""Base class for MIME specializations."""
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Errors
|
||||||
import Encoders
|
import Encoders
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MIMEImage(MIMEBase.MIMEBase):
|
class MIMEImage(MIMEBase.MIMEBase):
|
||||||
"""Class for generating image/* type MIME documents."""
|
"""Class for generating image/* type MIME documents."""
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Message
|
||||||
import MIMEBase
|
import MIMEBase
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MIMEMessage(MIMEBase.MIMEBase):
|
class MIMEMessage(MIMEBase.MIMEBase):
|
||||||
"""Class representing message/* MIME documents."""
|
"""Class representing message/* MIME documents."""
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import MIMEBase
|
||||||
from Encoders import encode_7or8bit
|
from Encoders import encode_7or8bit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MIMEText(MIMEBase.MIMEBase):
|
class MIMEText(MIMEBase.MIMEBase):
|
||||||
"""Class for generating text/* type MIME documents."""
|
"""Class for generating text/* type MIME documents."""
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ SEMISPACE = '; '
|
||||||
paramre = re.compile(r';\s*')
|
paramre = re.compile(r';\s*')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Message:
|
class Message:
|
||||||
"""Basic message object for use inside the object tree.
|
"""Basic message object for use inside the object tree.
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ class Message:
|
||||||
|
|
||||||
def get_charsets(self, failobj=None):
|
def get_charsets(self, failobj=None):
|
||||||
"""Return a list containing the charset(s) used in this message.
|
"""Return a list containing the charset(s) used in this message.
|
||||||
|
|
||||||
The returned list of items describes the Content-Type: headers'
|
The returned list of items describes the Content-Type: headers'
|
||||||
charset parameter for this message and all the subparts in its
|
charset parameter for this message and all the subparts in its
|
||||||
payload.
|
payload.
|
||||||
|
|
|
@ -14,7 +14,7 @@ EMPTYSTRING = ''
|
||||||
NL = '\n'
|
NL = '\n'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Parser:
|
class Parser:
|
||||||
def __init__(self, _class=Message.Message):
|
def __init__(self, _class=Message.Message):
|
||||||
"""Parser of RFC 2822 and MIME email messages.
|
"""Parser of RFC 2822 and MIME email messages.
|
||||||
|
|
|
@ -21,7 +21,7 @@ COMMASPACE = ', '
|
||||||
UEMPTYSTRING = u''
|
UEMPTYSTRING = u''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
|
|
||||||
def _identity(s):
|
def _identity(s):
|
||||||
|
@ -42,7 +42,7 @@ def _bdecode(s):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getaddresses(fieldvalues):
|
def getaddresses(fieldvalues):
|
||||||
"""Return a list of (REALNAME, EMAIL) for each fieldvalue."""
|
"""Return a list of (REALNAME, EMAIL) for each fieldvalue."""
|
||||||
all = COMMASPACE.join(fieldvalues)
|
all = COMMASPACE.join(fieldvalues)
|
||||||
|
@ -50,7 +50,7 @@ def getaddresses(fieldvalues):
|
||||||
return a.getaddrlist()
|
return a.getaddrlist()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ecre = re.compile(r'''
|
ecre = re.compile(r'''
|
||||||
=\? # literal =?
|
=\? # literal =?
|
||||||
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
|
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
|
||||||
|
@ -92,7 +92,7 @@ def decode(s):
|
||||||
return UEMPTYSTRING.join(rtn)
|
return UEMPTYSTRING.join(rtn)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def encode(s, charset='iso-8859-1', encoding='q'):
|
def encode(s, charset='iso-8859-1', encoding='q'):
|
||||||
"""Encode a string according to RFC 2047."""
|
"""Encode a string according to RFC 2047."""
|
||||||
if encoding.lower() == 'q':
|
if encoding.lower() == 'q':
|
||||||
|
|
|
@ -22,7 +22,7 @@ __all__ = ['Encoders',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Some convenience routines
|
# Some convenience routines
|
||||||
from Parser import Parser as _Parser
|
from Parser import Parser as _Parser
|
||||||
from Message import Message as _Message
|
from Message import Message as _Message
|
||||||
|
|
|
@ -12,10 +12,10 @@ HEX = '0123456789ABCDEF'
|
||||||
EMPTYSTRING = ''
|
EMPTYSTRING = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from binascii import a2b_qp, b2a_qp
|
from binascii import a2b_qp, b2a_qp
|
||||||
except:
|
except:
|
||||||
a2b_qp = None
|
a2b_qp = None
|
||||||
b2a_qp = None
|
b2a_qp = None
|
||||||
|
|
||||||
|
|
||||||
def needsquoting(c, quotetabs, header):
|
def needsquoting(c, quotetabs, header):
|
||||||
|
@ -28,7 +28,7 @@ def needsquoting(c, quotetabs, header):
|
||||||
if c in ' \t':
|
if c in ' \t':
|
||||||
return quotetabs
|
return quotetabs
|
||||||
# if header, we have to escape _ because _ is used to escape space
|
# if header, we have to escape _ because _ is used to escape space
|
||||||
if c == '_':
|
if c == '_':
|
||||||
return header
|
return header
|
||||||
return c == ESCAPE or not (' ' <= c <= '~')
|
return c == ESCAPE or not (' ' <= c <= '~')
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def encode(input, output, quotetabs, header = 0):
|
||||||
odata = b2a_qp(data, quotetabs = quotetabs, header = header)
|
odata = b2a_qp(data, quotetabs = quotetabs, header = header)
|
||||||
output.write(odata)
|
output.write(odata)
|
||||||
return
|
return
|
||||||
|
|
||||||
def write(s, output=output, lineEnd='\n'):
|
def write(s, output=output, lineEnd='\n'):
|
||||||
# RFC 1521 requires that the line ending in a space or tab must have
|
# RFC 1521 requires that the line ending in a space or tab must have
|
||||||
# that trailing character encoded.
|
# that trailing character encoded.
|
||||||
|
|
|
@ -28,14 +28,14 @@ NL = '\n'
|
||||||
EMPTYSTRING = ''
|
EMPTYSTRING = ''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def openfile(filename):
|
def openfile(filename):
|
||||||
path = os.path.join(os.path.dirname(test.regrtest.__file__),
|
path = os.path.join(os.path.dirname(test.regrtest.__file__),
|
||||||
'data', filename)
|
'data', filename)
|
||||||
return open(path)
|
return open(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Base test class
|
# Base test class
|
||||||
class TestEmailBase(unittest.TestCase):
|
class TestEmailBase(unittest.TestCase):
|
||||||
def _msgobj(self, filename):
|
def _msgobj(self, filename):
|
||||||
|
@ -47,12 +47,12 @@ class TestEmailBase(unittest.TestCase):
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Test various aspects of the Message class's API
|
# Test various aspects of the Message class's API
|
||||||
class TestMessageAPI(TestEmailBase):
|
class TestMessageAPI(TestEmailBase):
|
||||||
def test_get_charsets(self):
|
def test_get_charsets(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
|
|
||||||
msg = self._msgobj('msg_08.txt')
|
msg = self._msgobj('msg_08.txt')
|
||||||
charsets = msg.get_charsets()
|
charsets = msg.get_charsets()
|
||||||
eq(charsets, [None, 'us-ascii', 'iso-8859-1', 'iso-8859-2', 'koi8-r'])
|
eq(charsets, [None, 'us-ascii', 'iso-8859-1', 'iso-8859-2', 'koi8-r'])
|
||||||
|
@ -175,7 +175,7 @@ class TestMessageAPI(TestEmailBase):
|
||||||
msg = email.message_from_string(
|
msg = email.message_from_string(
|
||||||
"Content-Disposition: blarg; filename\n")
|
"Content-Disposition: blarg; filename\n")
|
||||||
self.assertEqual(msg.get_filename(), '')
|
self.assertEqual(msg.get_filename(), '')
|
||||||
|
|
||||||
def test_missing_boundary(self):
|
def test_missing_boundary(self):
|
||||||
msg = email.message_from_string("From: foo\n")
|
msg = email.message_from_string("From: foo\n")
|
||||||
self.assertEqual(msg.get_boundary(), None)
|
self.assertEqual(msg.get_boundary(), None)
|
||||||
|
@ -217,7 +217,7 @@ class TestMessageAPI(TestEmailBase):
|
||||||
self.failIf(msg.has_key('headeri'))
|
self.failIf(msg.has_key('headeri'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Test the email.Encoders module
|
# Test the email.Encoders module
|
||||||
class TestEncoders(unittest.TestCase):
|
class TestEncoders(unittest.TestCase):
|
||||||
def test_encode_noop(self):
|
def test_encode_noop(self):
|
||||||
|
@ -254,7 +254,7 @@ class TestEncoders(unittest.TestCase):
|
||||||
eq(msg['content-transfer-encoding'], 'quoted-printable')
|
eq(msg['content-transfer-encoding'], 'quoted-printable')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestLongHeaders(unittest.TestCase):
|
class TestLongHeaders(unittest.TestCase):
|
||||||
def test_header_splitter(self):
|
def test_header_splitter(self):
|
||||||
msg = MIMEText('')
|
msg = MIMEText('')
|
||||||
|
@ -271,12 +271,12 @@ Content-Type: text/plain; charset="us-ascii"
|
||||||
MIME-Version: 1.0
|
MIME-Version: 1.0
|
||||||
Content-Transfer-Encoding: 7bit
|
Content-Transfer-Encoding: 7bit
|
||||||
X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
|
X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
|
||||||
spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"
|
spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"
|
||||||
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestFromMangling(unittest.TestCase):
|
class TestFromMangling(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.msg = Message()
|
self.msg = Message()
|
||||||
|
@ -309,7 +309,7 @@ Blah blah blah
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Test the basic MIMEImage class
|
# Test the basic MIMEImage class
|
||||||
class TestMIMEImage(unittest.TestCase):
|
class TestMIMEImage(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -362,7 +362,7 @@ class TestMIMEImage(unittest.TestCase):
|
||||||
header='foobar') is missing)
|
header='foobar') is missing)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Test the basic MIMEText class
|
# Test the basic MIMEText class
|
||||||
class TestMIMEText(unittest.TestCase):
|
class TestMIMEText(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -383,7 +383,7 @@ class TestMIMEText(unittest.TestCase):
|
||||||
self.failUnless(not self._msg.is_multipart())
|
self.failUnless(not self._msg.is_multipart())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestMultipartMixed(unittest.TestCase):
|
class TestMultipartMixed(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
fp = openfile('PyBanner048.gif')
|
fp = openfile('PyBanner048.gif')
|
||||||
|
@ -406,7 +406,7 @@ This is the dingus fish.
|
||||||
container['From'] = 'Barry <barry@digicool.com>'
|
container['From'] = 'Barry <barry@digicool.com>'
|
||||||
container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>'
|
container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>'
|
||||||
container['Subject'] = 'Here is your dingus fish'
|
container['Subject'] = 'Here is your dingus fish'
|
||||||
|
|
||||||
now = 987809702.54848599
|
now = 987809702.54848599
|
||||||
timetuple = time.localtime(now)
|
timetuple = time.localtime(now)
|
||||||
if timetuple[-1] == 0:
|
if timetuple[-1] == 0:
|
||||||
|
@ -445,7 +445,7 @@ This is the dingus fish.
|
||||||
unless(not m1.is_multipart())
|
unless(not m1.is_multipart())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestNonConformant(TestEmailBase):
|
class TestNonConformant(TestEmailBase):
|
||||||
def test_parse_missing_minor_type(self):
|
def test_parse_missing_minor_type(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
|
@ -466,7 +466,7 @@ class TestNonConformant(TestEmailBase):
|
||||||
self.assertRaises(Errors.BoundaryError, p.parsestr, data)
|
self.assertRaises(Errors.BoundaryError, p.parsestr, data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestRFC2047(unittest.TestCase):
|
class TestRFC2047(unittest.TestCase):
|
||||||
def test_iso_8859_1(self):
|
def test_iso_8859_1(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
|
@ -497,7 +497,7 @@ class TestRFC2047(unittest.TestCase):
|
||||||
'=?iso-8859-2?b?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=')
|
'=?iso-8859-2?b?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestMIMEMessage(TestEmailBase):
|
class TestMIMEMessage(TestEmailBase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
fp = openfile('msg_11.txt')
|
fp = openfile('msg_11.txt')
|
||||||
|
@ -603,7 +603,7 @@ Your message cannot be delivered to the following recipients:
|
||||||
'<002001c144a6$8752e060$56104586@oxy.edu>')
|
'<002001c144a6$8752e060$56104586@oxy.edu>')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestIdempotent(unittest.TestCase):
|
class TestIdempotent(unittest.TestCase):
|
||||||
def _msgobj(self, filename):
|
def _msgobj(self, filename):
|
||||||
fp = openfile(filename)
|
fp = openfile(filename)
|
||||||
|
@ -652,7 +652,7 @@ class TestIdempotent(unittest.TestCase):
|
||||||
def test_mixed_with_image(self):
|
def test_mixed_with_image(self):
|
||||||
msg, text = self._msgobj('msg_06.txt')
|
msg, text = self._msgobj('msg_06.txt')
|
||||||
self._idempotent(msg, text)
|
self._idempotent(msg, text)
|
||||||
|
|
||||||
def test_multipart_report(self):
|
def test_multipart_report(self):
|
||||||
msg, text = self._msgobj('msg_05.txt')
|
msg, text = self._msgobj('msg_05.txt')
|
||||||
self._idempotent(msg, text)
|
self._idempotent(msg, text)
|
||||||
|
@ -660,7 +660,7 @@ class TestIdempotent(unittest.TestCase):
|
||||||
def test_dsn(self):
|
def test_dsn(self):
|
||||||
msg, text = self._msgobj('msg_16.txt')
|
msg, text = self._msgobj('msg_16.txt')
|
||||||
self._idempotent(msg, text)
|
self._idempotent(msg, text)
|
||||||
|
|
||||||
def test_content_type(self):
|
def test_content_type(self):
|
||||||
eq = self.assertEquals
|
eq = self.assertEquals
|
||||||
# Get a message object and reset the seek pointer for other tests
|
# Get a message object and reset the seek pointer for other tests
|
||||||
|
@ -701,9 +701,9 @@ class TestIdempotent(unittest.TestCase):
|
||||||
eq(msg1.get_type(), 'text/plain')
|
eq(msg1.get_type(), 'text/plain')
|
||||||
self.failUnless(isinstance(msg1.get_payload(), StringType))
|
self.failUnless(isinstance(msg1.get_payload(), StringType))
|
||||||
eq(msg1.get_payload(), '\n')
|
eq(msg1.get_payload(), '\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestMiscellaneous(unittest.TestCase):
|
class TestMiscellaneous(unittest.TestCase):
|
||||||
def test_message_from_string(self):
|
def test_message_from_string(self):
|
||||||
fp = openfile('msg_01.txt')
|
fp = openfile('msg_01.txt')
|
||||||
|
@ -744,7 +744,7 @@ class TestMiscellaneous(unittest.TestCase):
|
||||||
# Create a subclass
|
# Create a subclass
|
||||||
class MyMessage(Message):
|
class MyMessage(Message):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
msg = email.message_from_string(text, MyMessage)
|
msg = email.message_from_string(text, MyMessage)
|
||||||
unless(isinstance(msg, MyMessage))
|
unless(isinstance(msg, MyMessage))
|
||||||
# Try something more complicated
|
# Try something more complicated
|
||||||
|
@ -763,7 +763,7 @@ class TestMiscellaneous(unittest.TestCase):
|
||||||
# Create a subclass
|
# Create a subclass
|
||||||
class MyMessage(Message):
|
class MyMessage(Message):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
fp = openfile('msg_01.txt')
|
fp = openfile('msg_01.txt')
|
||||||
try:
|
try:
|
||||||
msg = email.message_from_file(fp, MyMessage)
|
msg = email.message_from_file(fp, MyMessage)
|
||||||
|
@ -780,7 +780,7 @@ class TestMiscellaneous(unittest.TestCase):
|
||||||
unless(isinstance(subpart, MyMessage))
|
unless(isinstance(subpart, MyMessage))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestIterators(TestEmailBase):
|
class TestIterators(TestEmailBase):
|
||||||
def test_body_line_iterator(self):
|
def test_body_line_iterator(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
|
@ -801,15 +801,15 @@ class TestIterators(TestEmailBase):
|
||||||
eq(len(lines), 43)
|
eq(len(lines), 43)
|
||||||
eq(EMPTYSTRING.join(lines), """\
|
eq(EMPTYSTRING.join(lines), """\
|
||||||
Send Ppp mailing list submissions to
|
Send Ppp mailing list submissions to
|
||||||
ppp@zzz.org
|
ppp@zzz.org
|
||||||
|
|
||||||
To subscribe or unsubscribe via the World Wide Web, visit
|
To subscribe or unsubscribe via the World Wide Web, visit
|
||||||
http://www.zzz.org/mailman/listinfo/ppp
|
http://www.zzz.org/mailman/listinfo/ppp
|
||||||
or, via email, send a message with subject or body 'help' to
|
or, via email, send a message with subject or body 'help' to
|
||||||
ppp-request@zzz.org
|
ppp-request@zzz.org
|
||||||
|
|
||||||
You can reach the person managing the list at
|
You can reach the person managing the list at
|
||||||
ppp-admin@zzz.org
|
ppp-admin@zzz.org
|
||||||
|
|
||||||
When replying, please edit your Subject line so it is more specific
|
When replying, please edit your Subject line so it is more specific
|
||||||
than "Re: Contents of Ppp digest..."
|
than "Re: Contents of Ppp digest..."
|
||||||
|
@ -863,7 +863,7 @@ to reflect upon our own
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
suite.addTest(unittest.makeSuite(TestMessageAPI))
|
suite.addTest(unittest.makeSuite(TestMessageAPI))
|
||||||
|
@ -882,7 +882,7 @@ def suite():
|
||||||
return suite
|
return suite
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(defaultTest='suite')
|
unittest.main(defaultTest='suite')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -648,7 +648,7 @@ class TestCase(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
self.assertRaises(TypeError, f.writelines, None)
|
self.assertRaises(TypeError, f.writelines, None)
|
||||||
self.assertRaises(TypeError, f.writelines, 42)
|
self.assertRaises(TypeError, f.writelines, 42)
|
||||||
|
|
||||||
f.writelines(["1\n", "2\n"])
|
f.writelines(["1\n", "2\n"])
|
||||||
f.writelines(("3\n", "4\n"))
|
f.writelines(("3\n", "4\n"))
|
||||||
f.writelines({'5\n': None})
|
f.writelines({'5\n': None})
|
||||||
|
@ -678,14 +678,14 @@ class TestCase(unittest.TestCase):
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return Iterator(self.start, self.finish)
|
return Iterator(self.start, self.finish)
|
||||||
|
|
||||||
f.writelines(Whatever(6, 6+2000))
|
f.writelines(Whatever(6, 6+2000))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
f = file(TESTFN)
|
f = file(TESTFN)
|
||||||
expected = [str(i) + "\n" for i in range(1, 2006)]
|
expected = [str(i) + "\n" for i in range(1, 2006)]
|
||||||
self.assertEqual(list(f), expected)
|
self.assertEqual(list(f), expected)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -7,7 +7,7 @@ import profile
|
||||||
# (We can't use a helper function increment the timer since it would be
|
# (We can't use a helper function increment the timer since it would be
|
||||||
# included in the profile and would appear to consume all the time.)
|
# included in the profile and would appear to consume all the time.)
|
||||||
ticks = 0
|
ticks = 0
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
global ticks
|
global ticks
|
||||||
ticks = 0
|
ticks = 0
|
||||||
|
|
|
@ -409,7 +409,7 @@ utfTests = [(u'A\u2262\u0391.', 'A+ImIDkQ.'), # RFC2152 example
|
||||||
for x,y in utfTests:
|
for x,y in utfTests:
|
||||||
verify( x.encode('utf-7') == y )
|
verify( x.encode('utf-7') == y )
|
||||||
|
|
||||||
try:
|
try:
|
||||||
unicode('+3ADYAA-', 'utf-7') # surrogates not supported
|
unicode('+3ADYAA-', 'utf-7') # surrogates not supported
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue