Skip to content

Commit

Permalink
Add full test coverage for fs_str func (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
atugushev authored Apr 6, 2019
1 parent 5097833 commit 9d0a91a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 0 additions & 5 deletions piptools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,6 @@ def fs_str(string):
On Python 3 returns the string as is, since Python 3 uses unicode
paths and the input string shouldn't be bytes.
>>> fs_str(u'some path component/Something')
'some path component/Something'
>>> assert isinstance(fs_str('whatever'), str)
>>> assert isinstance(fs_str(u'whatever'), str)
:type string: str|unicode
:rtype: str
"""
Expand Down
14 changes: 14 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import six
from pytest import mark, raises

from piptools.utils import (
Expand All @@ -6,6 +7,7 @@
flat_map,
format_requirement,
format_specifier,
fs_str,
get_hashes_from_ireq,
is_pinned_requirement,
name_from_req,
Expand Down Expand Up @@ -147,3 +149,15 @@ def test_name_from_req_with_project_name(from_line):
ireq = from_line("foo==1.8")
ireq.req.project_name = "bar"
assert name_from_req(ireq.req) == "bar"


def test_fs_str():
assert fs_str(u"some path component/Something") == "some path component/Something"
assert isinstance(fs_str("whatever"), str)
assert isinstance(fs_str(u"whatever"), str)


@mark.skipif(six.PY2, reason="Not supported in py2")
def test_fs_str_with_bytes():
with raises(AssertionError):
fs_str(b"whatever")

0 comments on commit 9d0a91a

Please sign in to comment.