Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
test.test_uu.UUFileTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_encode
def test_decode
def test_decode_filename
def test_decodetwice

Public Attributes

 tmpin
 tmpout

Private Member Functions

def _kill

Detailed Description

Definition at line 122 of file test_uu.py.


Member Function Documentation

def test.test_uu.UUFileTest._kill (   self,
  f 
) [private]

Definition at line 124 of file test_uu.py.

00124 
00125     def _kill(self, f):
00126         # close and remove file
00127         if f is None:
00128             return
00129         try:
00130             f.close()
00131         except (SystemExit, KeyboardInterrupt):
00132             raise
00133         except:
00134             pass
00135         try:
00136             os.unlink(f.name)
00137         except (SystemExit, KeyboardInterrupt):
00138             raise
00139         except:
00140             pass

Here is the caller graph for this function:

Definition at line 141 of file test_uu.py.

00141 
00142     def setUp(self):
00143         self.tmpin  = support.TESTFN + "i"
00144         self.tmpout = support.TESTFN + "o"

Here is the caller graph for this function:

Definition at line 145 of file test_uu.py.

00145 
00146     def tearDown(self):
00147         del self.tmpin
00148         del self.tmpout

Here is the caller graph for this function:

Definition at line 179 of file test_uu.py.

00179 
00180     def test_decode(self):
00181         f = None
00182         try:
00183             support.unlink(self.tmpin)
00184             f = open(self.tmpin, 'wb')
00185             f.write(encodedtextwrapped(0o644, self.tmpout))
00186             f.close()
00187 
00188             f = open(self.tmpin, 'rb')
00189             uu.decode(f)
00190             f.close()
00191 
00192             f = open(self.tmpout, 'rb')
00193             s = f.read()
00194             f.close()
00195             self.assertEqual(s, plaintext)
00196             # XXX is there an xp way to verify the mode?
00197         finally:
00198             self._kill(f)

Here is the call graph for this function:

Definition at line 199 of file test_uu.py.

00199 
00200     def test_decode_filename(self):
00201         f = None
00202         try:
00203             support.unlink(self.tmpin)
00204             f = open(self.tmpin, 'wb')
00205             f.write(encodedtextwrapped(0o644, self.tmpout))
00206             f.close()
00207 
00208             uu.decode(self.tmpin)
00209 
00210             f = open(self.tmpout, 'rb')
00211             s = f.read()
00212             f.close()
00213             self.assertEqual(s, plaintext)
00214         finally:
00215             self._kill(f)

Here is the call graph for this function:

Definition at line 216 of file test_uu.py.

00216 
00217     def test_decodetwice(self):
00218         # Verify that decode() will refuse to overwrite an existing file
00219         f = None
00220         try:
00221             f = io.BytesIO(encodedtextwrapped(0o644, self.tmpout))
00222 
00223             f = open(self.tmpin, 'rb')
00224             uu.decode(f)
00225             f.close()
00226 
00227             f = open(self.tmpin, 'rb')
00228             self.assertRaises(uu.Error, uu.decode, f)
00229             f.close()
00230         finally:
00231             self._kill(f)

Here is the call graph for this function:

Definition at line 149 of file test_uu.py.

00149 
00150     def test_encode(self):
00151         fin = fout = None
00152         try:
00153             support.unlink(self.tmpin)
00154             fin = open(self.tmpin, 'wb')
00155             fin.write(plaintext)
00156             fin.close()
00157 
00158             fin = open(self.tmpin, 'rb')
00159             fout = open(self.tmpout, 'wb')
00160             uu.encode(fin, fout, self.tmpin, mode=0o644)
00161             fin.close()
00162             fout.close()
00163 
00164             fout = open(self.tmpout, 'rb')
00165             s = fout.read()
00166             fout.close()
00167             self.assertEqual(s, encodedtextwrapped(0o644, self.tmpin))
00168 
00169             # in_file and out_file as filenames
00170             uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0o644)
00171             fout = open(self.tmpout, 'rb')
00172             s = fout.read()
00173             fout.close()
00174             self.assertEqual(s, encodedtextwrapped(0o644, self.tmpin))
00175 
00176         finally:
00177             self._kill(fin)
00178             self._kill(fout)

Here is the call graph for this function:


Member Data Documentation

Definition at line 142 of file test_uu.py.

Definition at line 143 of file test_uu.py.


The documentation for this class was generated from the following file: