Skip to content

Commit

Permalink
Ensure tests pass on Python3 #120
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne committed Dec 20, 2017
1 parent 7c7886f commit 116c5d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions fs/osfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def _to_sys_path(self, path, as_bytes=False):

if _NIX_PLATFORM:
root_path = self.root_path_native
path = path and fsencode(path) or path
sep = six.binary_type(sep)
os_sep = six.binary_type(os_sep)
path = fsencode(path)
sep = b'/'
os_sep = fsencode(os_sep)

sys_path = os.path.join(
root_path,
Expand Down
12 changes: 8 additions & 4 deletions tests/test_osfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ def test_unicode_paths(self):
shutil.rmtree(dir_path)

def test_non_decodable_unicode_paths(self):
from fs._fscompat import fsencode, fsdecode

dir_path = tempfile.mkdtemp()
try:
fs_dir_bytes = os.path.join(bytes(dir_path), b'some')
fs_dir_unicode = unicode(fs_dir_bytes)
fs_dir_bytes = os.path.join(fsencode(dir_path), b'some')
fs_dir_unicode = fsdecode(fs_dir_bytes)
os.mkdir(fs_dir_bytes)
with open(os.path.join(fs_dir_bytes, b'foo\xb1bar'), 'wb') as uf:
uf.write(b'')
Expand All @@ -110,10 +112,12 @@ def test_non_decodable_unicode_paths(self):
shutil.rmtree(dir_path)

def test_can_open_non_decodable_unicode_paths(self):
from fs._fscompat import fsencode, fsdecode

dir_path = tempfile.mkdtemp()
try:
fs_dir_bytes = os.path.join(bytes(dir_path), b'some')
fs_dir_unicode = unicode(fs_dir_bytes)
fs_dir_bytes = os.path.join(fsencode(dir_path), b'some')
fs_dir_unicode = fsdecode(fs_dir_bytes)
os.mkdir(fs_dir_bytes)
with open(os.path.join(fs_dir_bytes, b'foo\xb1bar'), 'wb') as uf:
uf.write(b'')
Expand Down

0 comments on commit 116c5d6

Please sign in to comment.