Skip to content

Commit 3b28770

Browse files
committed
Add two tests for the script interface.
1 parent 9235ea4 commit 3b28770

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Lib/test/test_quopri.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from test import test_support
22
import unittest
33

4-
from cStringIO import StringIO
4+
import sys, os, cStringIO
55
import quopri
66

77

@@ -145,16 +145,16 @@ def test_idempotent_string(self):
145145
@withpythonimplementation
146146
def test_encode(self):
147147
for p, e in self.STRINGS:
148-
infp = StringIO(p)
149-
outfp = StringIO()
148+
infp = cStringIO.StringIO(p)
149+
outfp = cStringIO.StringIO()
150150
quopri.encode(infp, outfp, quotetabs=False)
151151
self.assert_(outfp.getvalue() == e)
152152

153153
@withpythonimplementation
154154
def test_decode(self):
155155
for p, e in self.STRINGS:
156-
infp = StringIO(e)
157-
outfp = StringIO()
156+
infp = cStringIO.StringIO(e)
157+
outfp = cStringIO.StringIO()
158158
quopri.decode(infp, outfp)
159159
self.assert_(outfp.getvalue() == p)
160160

@@ -174,6 +174,20 @@ def test_decode_header(self):
174174
for p, e in self.HSTRINGS:
175175
self.assert_(quopri.decodestring(e, header=True) == p)
176176

177+
def test_scriptencode(self):
178+
(p, e) = self.STRINGS[-1]
179+
(cin, cout) = os.popen2("%s -mquopri" % sys.executable)
180+
cin.write(p)
181+
cin.close()
182+
self.assert_(cout.read() == e)
183+
184+
def test_scriptdecode(self):
185+
(p, e) = self.STRINGS[-1]
186+
(cin, cout) = os.popen2("%s -mquopri -d" % sys.executable)
187+
cin.write(e)
188+
cin.close()
189+
self.assert_(cout.read() == p)
190+
177191
def test_main():
178192
test_support.run_unittest(QuopriTestCase)
179193

0 commit comments

Comments
 (0)