Skip to content

zipfile.ZipFile does not create file in fake file system on Windows with Python 2.7.9 #103

Closed
@borismod

Description

@borismod

I am using zipfile package for creating zip file. The below test fails. Is there any way to make it work?

import os
import zipfile
from pyfakefs import fake_filesystem_unittest


class TestPackageBuilder(fake_filesystem_unittest.TestCase):
    def setUp(self):
        self.setUpPyfakefs()

    def test_zip(self):
        self.fs.CreateFile(u'C:\\work\\readme.txt', contents='')
        zip_file_path = os.path.join(u'c:\\work', 'some_file.zip')
        with zipfile.ZipFile(zip_file_path, 'w') as zip_file:
            zip_file.write(u'C:\\work\\readme.txt')

        self.assertFileExists(u'c:\\work\\some_file.zip')

    def assertFileExists(self, file_path):
        self.assertTrue(os.path.exists(file_path), msg='File {0} does not exist'.format(file_path))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions