Skip to content

Commit

Permalink
Fix failing check.path test on windows (#7077)
Browse files Browse the repository at this point in the history
  • Loading branch information
smackesey committed Mar 16, 2022
1 parent 3df4da6 commit 61c43eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parameters:
jobs:
- job: "dagster"
pool:
vmImage: "vs2017-win2016"
vmImage: "windows-2019"
strategy:
matrix:
${{ each py_version in parameters.py3_versions }}:
Expand Down
2 changes: 1 addition & 1 deletion python_modules/dagster/dagster/check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ def opt_path_param(obj: None, param_name: str, default: Union[str, PathLike]) ->

@overload
def opt_path_param(
obj: Union[str, PathLike], param_name: str, default: Union[str, PathLike]
obj: Union[str, PathLike], param_name: str, default: Optional[Union[str, PathLike]] = ...
) -> str:
...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,26 +1014,30 @@ def test_path_param():
from pathlib import Path

assert check.path_param("/a/b.csv", "path_param") == "/a/b.csv"
assert check.path_param(Path("/a/b.csv"), "path_param") == "/a/b.csv"
if sys.platform.startswith("win32"):
assert check.opt_path_param(Path("c:\\a\\b.csv"), "path_param") == "c:\\a\\b.csv"
else:
assert check.opt_path_param(Path("/a/b.csv"), "path_param") == "/a/b.csv"

with pytest.raises(ParameterCheckError):
check.path_param(None, "path_param")
check.path_param(None, "path_param") # type: ignore

with pytest.raises(ParameterCheckError):
check.path_param(0, "path_param")
check.path_param(0, "path_param") # type: ignore


def test_opt_path_param():
from pathlib import Path

assert check.opt_path_param("/a/b.csv", "path_param") == "/a/b.csv"
assert check.opt_path_param(Path("/a/b.csv"), "path_param") == "/a/b.csv"
if sys.platform.startswith("win32"):
assert check.opt_path_param(Path("c:\\a\\b.csv"), "path_param") == "c:\\a\\b.csv"
else:
assert check.opt_path_param(Path("/a/b.csv"), "path_param") == "/a/b.csv"
assert check.opt_path_param(None, "path_param") is None
assert check.opt_path_param(None, "path_param", "/a/b/c.csv") == "/a/b/c.csv"
assert check.opt_path_param(None, "path_param", Path("/a/b/c.csv")) == "/a/b/c.csv"

with pytest.raises(ParameterCheckError):
check.opt_path_param(0, "path_param")
check.opt_path_param(0, "path_param") # type: ignore


# ########################
Expand All @@ -1046,10 +1050,10 @@ def test_set_param():
assert check.set_param(frozenset(), "set_param") == set()

with pytest.raises(ParameterCheckError):
check.set_param(None, "set_param")
check.set_param(None, "set_param") # type: ignore

with pytest.raises(ParameterCheckError):
check.set_param("3u4", "set_param")
check.set_param("3u4", "set_param") # type: ignore

obj_set = {1}
assert check.set_param(obj_set, "set_param") == obj_set
Expand All @@ -1073,13 +1077,10 @@ def test_opt_set_param():
assert check.opt_set_param({3}, "set_param") == {3}

with pytest.raises(ParameterCheckError):
check.opt_set_param(0, "set_param")

with pytest.raises(ParameterCheckError):
check.opt_set_param("", "set_param")
check.opt_set_param(0, "set_param") # type: ignore

with pytest.raises(ParameterCheckError):
check.opt_set_param("3u4", "set_param")
check.opt_set_param("3u4", "set_param") # type: ignore


# ########################
Expand Down

0 comments on commit 61c43eb

Please sign in to comment.