mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Add two tests for the script interface.
This commit is contained in:
parent
9235ea4f26
commit
3b287702dd
1 changed files with 19 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
from test import test_support
|
from test import test_support
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from cStringIO import StringIO
|
import sys, os, cStringIO
|
||||||
import quopri
|
import quopri
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,16 +145,16 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
|
||||||
@withpythonimplementation
|
@withpythonimplementation
|
||||||
def test_encode(self):
|
def test_encode(self):
|
||||||
for p, e in self.STRINGS:
|
for p, e in self.STRINGS:
|
||||||
infp = StringIO(p)
|
infp = cStringIO.StringIO(p)
|
||||||
outfp = StringIO()
|
outfp = cStringIO.StringIO()
|
||||||
quopri.encode(infp, outfp, quotetabs=False)
|
quopri.encode(infp, outfp, quotetabs=False)
|
||||||
self.assert_(outfp.getvalue() == e)
|
self.assert_(outfp.getvalue() == e)
|
||||||
|
|
||||||
@withpythonimplementation
|
@withpythonimplementation
|
||||||
def test_decode(self):
|
def test_decode(self):
|
||||||
for p, e in self.STRINGS:
|
for p, e in self.STRINGS:
|
||||||
infp = StringIO(e)
|
infp = cStringIO.StringIO(e)
|
||||||
outfp = StringIO()
|
outfp = cStringIO.StringIO()
|
||||||
quopri.decode(infp, outfp)
|
quopri.decode(infp, outfp)
|
||||||
self.assert_(outfp.getvalue() == p)
|
self.assert_(outfp.getvalue() == p)
|
||||||
|
|
||||||
|
@ -174,6 +174,20 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
|
||||||
for p, e in self.HSTRINGS:
|
for p, e in self.HSTRINGS:
|
||||||
self.assert_(quopri.decodestring(e, header=True) == p)
|
self.assert_(quopri.decodestring(e, header=True) == p)
|
||||||
|
|
||||||
|
def test_scriptencode(self):
|
||||||
|
(p, e) = self.STRINGS[-1]
|
||||||
|
(cin, cout) = os.popen2("%s -mquopri" % sys.executable)
|
||||||
|
cin.write(p)
|
||||||
|
cin.close()
|
||||||
|
self.assert_(cout.read() == e)
|
||||||
|
|
||||||
|
def test_scriptdecode(self):
|
||||||
|
(p, e) = self.STRINGS[-1]
|
||||||
|
(cin, cout) = os.popen2("%s -mquopri -d" % sys.executable)
|
||||||
|
cin.write(e)
|
||||||
|
cin.close()
|
||||||
|
self.assert_(cout.read() == p)
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(QuopriTestCase)
|
test_support.run_unittest(QuopriTestCase)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue