Fix paths from assignment test on Windows

This commit is contained in:
micbou
2018-01-12 22:11:42 +01:00
committed by Dave Halter
parent 2283b67836
commit 51b44032bd

View File

@@ -15,9 +15,14 @@ def test_paths_from_assignment(Script):
expr_stmt = script._module_node.children[0] expr_stmt = script._module_node.children[0]
return set(sys_path._paths_from_assignment(script._get_module(), expr_stmt)) return set(sys_path._paths_from_assignment(script._get_module(), expr_stmt))
assert paths('sys.path[0:0] = ["a"]') == {'/foo/a'} # Normalize paths for Windows.
assert paths('sys.path = ["b", 1, x + 3, y, "c"]') == {'/foo/b', '/foo/c'} path_a = os.path.abspath('/foo/a')
assert paths('sys.path = a = ["a"]') == {'/foo/a'} path_b = os.path.abspath('/foo/b')
path_c = os.path.abspath('/foo/c')
assert paths('sys.path[0:0] = ["a"]') == {path_a}
assert paths('sys.path = ["b", 1, x + 3, y, "c"]') == {path_b, path_c}
assert paths('sys.path = a = ["a"]') == {path_a}
# Fail for complicated examples. # Fail for complicated examples.
assert paths('sys.path, other = ["a"], 2') == set() assert paths('sys.path, other = ["a"], 2') == set()