Ejemplo n.º 1
0
    def setUp(self):
        self.filenames = {}
        self.uncompressed_filenames = {}
        
        for compression_format in COMPRESSION_FORMATS.keys():
            filename = tempfile.mktemp(suffix='.gz')
            uncompressed_filename = tempfile.mktemp()

            with open(uncompressed_filename, 'w+') as f:
                text = ' 1. This is the first line of content\n'
                f.write(text)
                text = ' 2. This is the second line of content\n'
                f.write(text)
            self.filenames[compression_format] = filename
            self.uncompressed_filenames[compression_format] = uncompressed_filename
    def setUp(self):
        self.filenames = {}
        self.uncompressed_filenames = {}
        
        for compression_format in COMPRESSION_FORMATS.keys():
            filename = tempfile.mktemp(suffix='.gz')
            uncompressed_filename = tempfile.mktemp()

            with file(uncompressed_filename, 'w+') as f:
                text = ' 1. This is the first line of content\n'
                f.write(text)
                text = ' 2. This is the second line of content\n'
                f.write(text)
            self.filenames[compression_format] = filename
            self.uncompressed_filenames[compression_format] = uncompressed_filename
Ejemplo n.º 3
0
    def test_fromfile(self):
        '''
        Create the compressed file from an existing one and compare the
        contents of the compressed version.
        '''
        for compression_format in COMPRESSION_FORMATS.keys():
            filename = self.filenames[compression_format]
            uncompressed_filename = self.uncompressed_filenames[compression_format]
            # Create the compressed version first
            cf = CompressedFile(filename, uncompressed_filename)
            cf.compress()

            with open(uncompressed_filename) as f:
                expected = f.readlines()
    
            # next uncompress the file and compare the contents
            with CompressedFile(filename) as uncompressed:
                with open(uncompressed) as f:
                    self.assertListEqual(f.readlines(), expected)
    def test_fromfile(self):
        '''
        Create the compressed file from an existing one and compare the
        contents of the compressed version.
        '''
        for compression_format in COMPRESSION_FORMATS.keys():
            filename = self.filenames[compression_format]
            uncompressed_filename = self.uncompressed_filenames[compression_format]
            # Create the compressed version first
            cf = CompressedFile(filename, uncompressed_filename)
            cf.compress()

            with file(uncompressed_filename) as f:
                expected = f.readlines()
    
            # next uncompress the file and compare the contents
            with CompressedFile(filename) as uncompressed:
                with file(uncompressed) as f:
                    self.assertListEqual(f.readlines(), expected)
Ejemplo n.º 5
0
 def setUp(self):
     self.filenames = []
     for compression_format in COMPRESSION_FORMATS.keys():
         suffix = '.%s' % compression_format
         self.filenames.append(tempfile.mktemp(suffix=suffix))
 def setUp(self):
     self.filenames = []
     for compression_format in COMPRESSION_FORMATS.keys():
         suffix = '.%s' % compression_format
         self.filenames.append(tempfile.mktemp(suffix=suffix))