Skip to content

Commit

Permalink
Allow hash in filename Fix #92 (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmylk committed Oct 5, 2016
1 parent 37e036b commit 63fa57f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion smart_open/smart_open_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def __init__(self, uri, default_scheme="file"):
if '://' not in uri:
# no protocol given => assume a local file
uri = 'file://' + uri
parsed_uri = urlsplit(uri)
parsed_uri = urlsplit(uri, allow_fragments=False)
self.scheme = parsed_uri.scheme if parsed_uri.scheme else default_scheme

if self.scheme == "hdfs":
Expand Down
16 changes: 16 additions & 0 deletions smart_open/tests/test_smart_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ def test_file(self, mock_smart_open):
# called with the correct path?
mock_smart_open.assert_called_with(full_path, read_mode)

full_path = '/tmp/test#hash##more.txt'
read_mode = "rb"
smart_open_object = smart_open.smart_open(prefix+full_path, read_mode)
smart_open_object.__iter__()
# called with the correct path?
mock_smart_open.assert_called_with(full_path, read_mode)


full_path = 'aa#aa'
read_mode = "rb"
smart_open_object = smart_open.smart_open(full_path, read_mode)
smart_open_object.__iter__()
# called with the correct path?
mock_smart_open.assert_called_with(full_path, read_mode)


short_path = "~/tmp/test.txt"
full_path = os.path.expanduser(short_path)

Expand Down

0 comments on commit 63fa57f

Please sign in to comment.