Ejemplo n.º 1
0
    def testSortsInfos(self):
        """There was an error because calling infolist() on the two zip files
        was not giving a consistent result.
        So we mock to force this situation,
        and test ensure the code handles this platform-dependent edge case.
        """
        old_infolist = zipfile.ZipFile.infolist
        shuffled = []

        def infolist(zself):
            result = old_infolist(zself)
            names = [z.filename for z in result]
            if names in shuffled:
                result = itertoolsext.shuffle(result, 500)
            shuffled.append(names)
            return result

        def create_zip():
            return self.createZip(
                [['1.a', '1'],
                 ['2.b', '2'],
                 ['3.c', '3']])

        with testhelpers.Patcher(zipfile.ZipFile, 'infolist', infolist):
            zu.compare_zip_files(create_zip(), create_zip())
Ejemplo n.º 2
0
 def docompare():
     return zu.compare_zip_files(self.createZip([]), self.createZip([]))
Ejemplo n.º 3
0
 def testEqualZips(self):
     f1 = self.createZip()
     f2 = self.createZip()
     zu.compare_zip_files(f1, f2)
Ejemplo n.º 4
0
 def assertAssertsWithMsg(self, z1, z2, msg):
     try:
         zu.compare_zip_files(z1, z2)
         self.fail('Should  have raised')
     except zu.FileComparisonError as ex:
         self.assertEqual(ex.args[0], msg)