Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths are case sensitive even on Windows, which is case insensitive #69

Closed
ismacaulay opened this issue Jan 23, 2016 · 8 comments
Closed
Labels

Comments

@ismacaulay
Copy link

Paths in windows are not case sensitive so windows treats the directory Tmp and tmp as the same directory. pyfakefs will actually treat them as 2 different directories. For example:

class MyTestCase(fake_filesystem_unittest.TestCase):
    def setUp(self):
        os.makedirs('Tmp')
        f = open(os.path.join('Tmp', 'test2.txt'), 'wb')
        f.close()
        f = open(os.path.join('tmp', 'test.txt'), 'wb')
        f.close()

        self.setUpPyfakefs()

        self.fs.CreateDirectory('Tmp')
        f = open(os.path.join('Tmp', 'test2.txt'), 'wb')
        f.close()
        f = open(os.path.join('tmp', 'test.txt'), 'wb')
        f.close()

    def test_test(self):
        pass

will give the following stack trace:

Error
Traceback (most recent call last):
  File "C:\Python27\lib\unittest\case.py", line 320, in run
  File "C:\workspaces\dem\dem\test\Test.py", line 21, in setUp
  File "C:\Python27\lib\site-packages\pyfakefs\fake_filesystem.py", line 1896, in __call__
  File "C:\Python27\lib\site-packages\pyfakefs\fake_filesystem.py", line 1904, in _call_ver2
  File "C:\Python27\lib\site-packages\pyfakefs\fake_filesystem.py", line 1968, in Call
  File "C:\Python27\lib\site-packages\pyfakefs\fake_filesystem.py", line 955, in CreateFile
IOError: [Errno 2] No such fake directory: '\\tmp'

The Tmp directory created before setting up pyfakefs in the test with have both test.txt and test2.txt, meaning that python did not care about the capital T. This causes problems when a module has become dependent on this behavior, especially when it is a 3rd party module.

@mrbean-bremen
Copy link
Member

I had the same problem but could solve it for the time being by consolidating the paths. As I expect to have the problem again (I started using PyFakeFS only a couple of weeks ago, and work under Windows), I thought about adding support for case-insensitive file system. I would prefer not to make it dependent on the underlying file system though, but add an option in file system init instead (similar to to pull request I submitted for an additional path separator). What do you think?

@jmcgeheeiv jmcgeheeiv changed the title Paths are case sensitive on windows in pyfakefs when python is case insensitive Paths are case sensitive even on Windows, which is case insensitive Apr 6, 2016
@jmcgeheeiv
Copy link
Contributor

@mrbean-bremen, it would be great if you could make pyfakefs automatically go into "Windows mode" on the Windows platform.

@mrbean-bremen
Copy link
Member

Ok, I will have a go at this after I'm done with pull request #77.

@jmcgeheeiv
Copy link
Contributor

I merged pull request #81, which should fix this. Please verify that you are satisfied.

@mrbean-bremen
Copy link
Member

Just for the record: I executed the exact test as given in the original post, and it runs fine now.

@jmcgeheeiv
Copy link
Contributor

Nice job. If you are satisfied that this is complete, please close this issue.

Do you think that issue #28 can also be closed?

@mrbean-bremen
Copy link
Member

About #28 - yes, I think so. I'm not sure if the original poster had any other problem, but I don't see any more Windows-specific problems at the moment (apart from the drive letter problem I made a small PR for). Though I'm going to use pyfakefs in the future under Windows, so I may find something else... I will also run the existing tests under Windows occasionally - feel free to ask for Windows tests if you need to check something.
About closing this issue - maybe the original creator will close it sometime.

@jmcgeheeiv
Copy link
Contributor

Thank you for your offer of testing on Windows. I will be taking you up on that.

Closing this issue since the original poster's test passes on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants