Skip to content

Commit

Permalink
Merge pull request #307 from radish-bdd/bugfix/windows_basepaths
Browse files Browse the repository at this point in the history
Fix #221 flattened_basedirs on Windows by ; instead of :
  • Loading branch information
timofurrer committed Feb 9, 2019
2 parents ab7e7a6 + b40c523 commit 2723dbf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/commandline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ containing steps and terrain functions from multiple locations:
Since version v0.7.0 you can use multiple basedirs within one ``-b`` flag split
by a colon (:). Similar to the possibilities you've got with ``$PATH``.
On Windows it is not possbile to use a colon (:) because it is used
in almost any absolute path, e.g. ``C:\foo\bar``.
Since version v0.11.2 you can use a semicolon (;) on Windows for
multiple basedirs.


Run - Early exit
Expand Down
3 changes: 2 additions & 1 deletion radish/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,5 @@ def flattened_basedirs(basedirs):
Multiple basedirs can be specified within a
single element split by a colon.
"""
return list(x for x in itertools.chain(*(x.split(":") for x in basedirs)) if x)
separator = ";" if os.name == "nt" else ":"
return list(x for x in itertools.chain(*(x.split(separator) for x in basedirs)) if x)
14 changes: 9 additions & 5 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,26 @@


@pytest.mark.parametrize(
"basedirs, expected_basedirs",
"basedirs, expected_basedirs, os_name",
[
(["foo", "bar"], ["foo", "bar"]),
(["foo:bar", "foobar"], ["foo", "bar", "foobar"]),
(["foo", "bar"], ["foo", "bar"], "posix"),
(["foo:bar", "foobar"], ["foo", "bar", "foobar"], "posix"),
(
["foo:bar", "foobar", "one:two:three"],
["foo", "bar", "foobar", "one", "two", "three"],
"posix"
),
(["foo:", ":bar"], ["foo", "bar"]),
(["foo:", ":bar"], ["foo", "bar"], "posix"),
(["C:\\windows\\radish"], ["C:\\windows\\radish"], "nt"),
(["C:\\windows;radish"], ["C:\\windows", "radish"], "nt"),
],
)
def test_flattened_basedirs(basedirs, expected_basedirs):
def test_flattened_basedirs(mocker, basedirs, expected_basedirs, os_name):
"""
Test flatten basedirs
"""
# given & when
mocker.patch("os.name", os_name)
actual_basedirs = utils.flattened_basedirs(basedirs)

# then
Expand Down

0 comments on commit 2723dbf

Please sign in to comment.