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

Behavior difference for os.path.split #632

Closed
c1728p9 opened this issue Sep 1, 2021 · 3 comments · Fixed by #633
Closed

Behavior difference for os.path.split #632

c1728p9 opened this issue Sep 1, 2021 · 3 comments · Fixed by #633
Labels

Comments

@c1728p9
Copy link

c1728p9 commented Sep 1, 2021

Describe the bug
On windows, the function python version of os.path.split does not convert path separators, while the pyfakefs version does. Is this intentional or is this a bug?

How To Reproduce

import os
import unittest
from pyfakefs.fake_filesystem_unittest import TestCase


class TestPathSplit(TestCase):

    def test_split(self):
        head_before, tail_before = os.path.split('/')
        self.setUpPyfakefs()
        head_after, tail_after = os.path.split('/')
        print("Before setUpPyfakefs head=%s, tail=%s" % (head_before, tail_before))
        print("After  setUpPyfakefs head=%s, tail=%s" % (head_after, tail_after))
        self.assertEqual(head_before, head_after)

if __name__ == '__main__':
    unittest.main()
>test.py          
Before setUpPyfakefs head=/, tail=
After  setUpPyfakefs head=\, tail=
F
======================================================================
FAIL: test_split (__main__.TestPathSplit)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Russ\Desktop\backup-tool\bug-report\test.py", line 14, in test_split
    self.assertEqual(head_before, head_after)
AssertionError: '/' != '\\'
- /
+ \

Your environment

>python -c "import platform; print(platform.platform())"
Windows-10-10.0.19041-SP0

>python -c "import sys; print('Python', sys.version)"
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]

>python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)"
pyfakefs 4.5.0
@mrbean-bremen
Copy link
Member

Thanks - no, that is not intentional.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Sep 1, 2021
- affects os.path.split, os.path.splitdrive and glob.glob
- fixes pytest-dev#632
mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Sep 1, 2021
- affects os.path.split(), os.path.splitdrive() and glob.glob()
- fixes pytest-dev#632
mrbean-bremen added a commit that referenced this issue Sep 1, 2021
- affects os.path.split(), os.path.splitdrive() and glob.glob()
- fixes #632
@mrbean-bremen
Copy link
Member

Shall be fixed in master now, please check!

github-actions bot pushed a commit that referenced this issue Sep 1, 2021
…cts os.path.split(), os.path.splitdrive() and glob.glob() - fixes #632
@c1728p9
Copy link
Author

c1728p9 commented Sep 5, 2021

@c1728p9 I gave this a try today with the tip of master (e06472b) and can confirm that this fixes the problem I was seeing. Thanks for the quick fix!

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

Successfully merging a pull request may close this issue.

2 participants