Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_zipfile.UniversalNewlineTests Class Reference

List of all members.

Public Member Functions

def setUp
def make_test_archive
def read_test
def readline_read_test
def readline_test
def readlines_test
def iterlines_test
def test_read_stored
def test_readline_read_stored
def test_readline_stored
def test_readlines_stored
def test_iterlines_stored
def test_read_deflated
def test_readline_read_deflated
def test_readline_deflated
def test_readlines_deflated
def test_iterlines_deflated
def tearDown

Public Attributes

 line_gen
 seps
 arcfiles

Detailed Description

Definition at line 1312 of file test_zipfile.py.


Member Function Documentation

def test.test_zipfile.UniversalNewlineTests.iterlines_test (   self,
  f,
  compression 
)

Definition at line 1396 of file test_zipfile.py.

01396 
01397     def iterlines_test(self, f, compression):
01398         self.make_test_archive(f, compression)
01399 
01400         # Read the ZIP archive
01401         with zipfile.ZipFile(f, "r") as zipfp:
01402             for sep, fn in self.arcfiles.items():
01403                 with zipfp.open(fn, "rU") as fp:
01404                     for line, zipline in zip(self.line_gen, fp):
01405                         self.assertEqual(zipline, line + b'\n')
01406         if not isinstance(f, str):
01407             f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_zipfile.UniversalNewlineTests.make_test_archive (   self,
  f,
  compression 
)

Definition at line 1328 of file test_zipfile.py.

01328 
01329     def make_test_archive(self, f, compression):
01330         # Create the ZIP archive
01331         with zipfile.ZipFile(f, "w", compression) as zipfp:
01332             for fn in self.arcfiles.values():
01333                 zipfp.write(fn, fn)

Here is the caller graph for this function:

def test.test_zipfile.UniversalNewlineTests.read_test (   self,
  f,
  compression 
)

Definition at line 1334 of file test_zipfile.py.

01334 
01335     def read_test(self, f, compression):
01336         self.make_test_archive(f, compression)
01337 
01338         # Read the ZIP archive
01339         with zipfile.ZipFile(f, "r") as zipfp:
01340             for sep, fn in self.arcfiles.items():
01341                 with zipfp.open(fn, "rU") as fp:
01342                     zipdata = fp.read()
01343                 self.assertEqual(self.arcdata[sep], zipdata)
01344         if not isinstance(f, str):
01345             f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_zipfile.UniversalNewlineTests.readline_read_test (   self,
  f,
  compression 
)

Definition at line 1346 of file test_zipfile.py.

01346 
01347     def readline_read_test(self, f, compression):
01348         self.make_test_archive(f, compression)
01349 
01350         # Read the ZIP archive
01351         with zipfile.ZipFile(f, "r") as zipfp:
01352             for sep, fn in self.arcfiles.items():
01353                 with zipfp.open(fn, "rU") as zipopen:
01354                     data = b''
01355                     while True:
01356                         read = zipopen.readline()
01357                         if not read:
01358                             break
01359                         data += read
01360 
01361                         read = zipopen.read(5)
01362                         if not read:
01363                             break
01364                         data += read
01365 
01366             self.assertEqual(data, self.arcdata['\n'])
01367 
01368         if not isinstance(f, str):
01369             f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_zipfile.UniversalNewlineTests.readline_test (   self,
  f,
  compression 
)

Definition at line 1370 of file test_zipfile.py.

01370 
01371     def readline_test(self, f, compression):
01372         self.make_test_archive(f, compression)
01373 
01374         # Read the ZIP archive
01375         with zipfile.ZipFile(f, "r") as zipfp:
01376             for sep, fn in self.arcfiles.items():
01377                 with zipfp.open(fn, "rU") as zipopen:
01378                     for line in self.line_gen:
01379                         linedata = zipopen.readline()
01380                         self.assertEqual(linedata, line + b'\n')
01381         if not isinstance(f, str):
01382             f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_zipfile.UniversalNewlineTests.readlines_test (   self,
  f,
  compression 
)

Definition at line 1383 of file test_zipfile.py.

01383 
01384     def readlines_test(self, f, compression):
01385         self.make_test_archive(f, compression)
01386 
01387         # Read the ZIP archive
01388         with zipfile.ZipFile(f, "r") as zipfp:
01389             for sep, fn in self.arcfiles.items():
01390                 with zipfp.open(fn, "rU") as fp:
01391                     ziplines = fp.readlines()
01392                 for line, zipline in zip(self.line_gen, ziplines):
01393                     self.assertEqual(zipline, line + b'\n')
01394         if not isinstance(f, str):
01395             f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1313 of file test_zipfile.py.

01313 
01314     def setUp(self):
01315         self.line_gen = [bytes("Test of zipfile line %d." % i, "ascii")
01316                          for i in range(FIXEDTEST_SIZE)]
01317         self.seps = ('\r', '\r\n', '\n')
01318         self.arcdata, self.arcfiles = {}, {}
01319         for n, s in enumerate(self.seps):
01320             b = s.encode("ascii")
01321             self.arcdata[s] = b.join(self.line_gen) + b
01322             self.arcfiles[s] = '%s-%d' % (TESTFN, n)
01323             f = open(self.arcfiles[s], "wb")
01324             try:
01325                 f.write(self.arcdata[s])
01326             finally:
01327                 f.close()

Here is the caller graph for this function:

Definition at line 1455 of file test_zipfile.py.

01455 
01456     def tearDown(self):
01457         for sep, fn in self.arcfiles.items():
01458             os.remove(fn)
01459         unlink(TESTFN)
01460         unlink(TESTFN2)
01461 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1451 of file test_zipfile.py.

01451 
01452     def test_iterlines_deflated(self):
01453         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01454             self.iterlines_test(f, zipfile.ZIP_DEFLATED)

Here is the call graph for this function:

Definition at line 1425 of file test_zipfile.py.

01425 
01426     def test_iterlines_stored(self):
01427         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01428             self.iterlines_test(f, zipfile.ZIP_STORED)

Here is the call graph for this function:

Definition at line 1430 of file test_zipfile.py.

01430 
01431     def test_read_deflated(self):
01432         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01433             self.read_test(f, zipfile.ZIP_DEFLATED)

Here is the call graph for this function:

Definition at line 1408 of file test_zipfile.py.

01408 
01409     def test_read_stored(self):
01410         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01411             self.read_test(f, zipfile.ZIP_STORED)

Here is the call graph for this function:

Definition at line 1441 of file test_zipfile.py.

01441 
01442     def test_readline_deflated(self):
01443         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01444             self.readline_test(f, zipfile.ZIP_DEFLATED)

Here is the call graph for this function:

Definition at line 1435 of file test_zipfile.py.

01435 
01436     def test_readline_read_deflated(self):
01437         # Issue #7610: calls to readline() interleaved with calls to read().
01438         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01439             self.readline_read_test(f, zipfile.ZIP_DEFLATED)

Here is the call graph for this function:

Definition at line 1412 of file test_zipfile.py.

01412 
01413     def test_readline_read_stored(self):
01414         # Issue #7610: calls to readline() interleaved with calls to read().
01415         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01416             self.readline_read_test(f, zipfile.ZIP_STORED)

Here is the call graph for this function:

Definition at line 1417 of file test_zipfile.py.

01417 
01418     def test_readline_stored(self):
01419         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01420             self.readline_test(f, zipfile.ZIP_STORED)

Here is the call graph for this function:

Definition at line 1446 of file test_zipfile.py.

01446 
01447     def test_readlines_deflated(self):
01448         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01449             self.readlines_test(f, zipfile.ZIP_DEFLATED)

Here is the call graph for this function:

Definition at line 1421 of file test_zipfile.py.

01421 
01422     def test_readlines_stored(self):
01423         for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
01424             self.readlines_test(f, zipfile.ZIP_STORED)

Here is the call graph for this function:


Member Data Documentation

Definition at line 1317 of file test_zipfile.py.

Definition at line 1314 of file test_zipfile.py.

Definition at line 1316 of file test_zipfile.py.


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