示例#1
0
def test_unpack(ZipFile, guess_file_type):
    "unpack() Should unpack zip files and return the names inside of the archive"

    # Given a zip package
    guess_file_type.return_value = 'zip'
    ZipFile.return_value.namelist.return_value = ['file.py', 'setup.py']

    # When I try to unpack a file
    open_archive, namelist = curdler.unpack('package.zip')

    # Then I see it returned an open archive
    open_archive.should.equal(ZipFile.return_value)

    # Then I see the right name list being returned
    namelist.should.equal(['file.py', 'setup.py'])
示例#2
0
def test_unpack(ZipFile, guess_file_type):
    "unpack() Should unpack zip files and return the names inside of the archive"

    # Given a zip package
    guess_file_type.return_value = 'zip'
    ZipFile.return_value.namelist.return_value = ['file.py', 'setup.py']

    # When I try to unpack a file
    open_archive, namelist = curdler.unpack('package.zip')

    # Then I see it returned an open archive
    open_archive.should.equal(ZipFile.return_value)

    # Then I see the right name list being returned
    namelist.should.equal(['file.py', 'setup.py'])
示例#3
0
def test_unpack_tarball(tarfile_open, guess_file_type):
    "unpack() Should unpack .gz files and return the names inside of the archive"

    # Given a zip package
    guess_file_type.return_value = 'gz'
    file1, file2 = Mock(), Mock()
    file1.name, file2.name = 'file.py', 'setup.py'
    tarfile_open.return_value.getmembers.return_value = [file1, file2]

    # When I try to unpack a file
    open_archive, namelist = curdler.unpack('package.tar.gz')

    # Then I see it returned an open archive
    open_archive.should.equal(tarfile_open.return_value)

    # Then I see the right name list being returned
    namelist.should.equal(['file.py', 'setup.py'])
示例#4
0
def test_unpack_tarball(tarfile_open, guess_file_type):
    "unpack() Should unpack .gz files and return the names inside of the archive"

    # Given a zip package
    guess_file_type.return_value = 'gz'
    file1, file2 = Mock(), Mock()
    file1.name, file2.name = 'file.py', 'setup.py'
    tarfile_open.return_value.getmembers.return_value = [file1, file2]

    # When I try to unpack a file
    open_archive, namelist = curdler.unpack('package.tar.gz')

    # Then I see it returned an open archive
    open_archive.should.equal(tarfile_open.return_value)

    # Then I see the right name list being returned
    namelist.should.equal(['file.py', 'setup.py'])