Skip to content

Commit

Permalink
Failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Jun 5, 2023
1 parent e387a8c commit cba6797
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/rust/engine/dep_inference/src/python/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fn simple_imports() {
assert_imports("import a.b", &["a.b"]);
assert_imports("import a as x", &["a"]);
assert_imports("from a import b", &["a.b"]);
assert_imports("from a import *", &["a"]);
assert_imports("from a.b import c", &["a.b.c"]);
assert_imports("from a.b import c.d", &["a.b.c.d"]);
assert_imports("from a.b import c, d, e", &["a.b.c", "a.b.d", "a.b.e"]);
Expand Down Expand Up @@ -87,6 +88,11 @@ from a.b import (
assert_imports("from ....a import b, c", &["....a.b", "....a.c"]);
assert_imports("from ....a import b as d, c", &["....a.b", "....a.c"]);

assert_imports("from .a import *", &[".a"]);
assert_imports("from . import *", &["."]);
assert_imports("from ..a import *", &["..a"]);
assert_imports("from .. import *", &[".."]);

assert_imports(
"class X: def method(): if True: while True: class Y: def f(): import a",
&["a"],
Expand Down Expand Up @@ -489,8 +495,11 @@ fn assert_relative_imports(filename: &str, code: &str, resolved_imports: &[&str]
fn relative_imports_resolution() {
let filename = "foo/bar/baz.py";
assert_relative_imports(filename, "from . import b", &["foo.bar.b"]);
assert_relative_imports(filename, "from . import *", &["foo.bar"]);
assert_relative_imports(filename, "from .a import b", &["foo.bar.a.b"]);
assert_relative_imports(filename, "from .a import *", &["foo.bar.a"]);
assert_relative_imports(filename, "from .. import b", &["foo.b"]);
assert_relative_imports(filename, "from .. import *", &["foo"]);
assert_relative_imports(filename, "from ..a import b", &["foo.a.b"]);
assert_relative_imports(filename, "from .. import b.c", &["foo.b.c"]);
assert_relative_imports(filename, "from ..a import b.c", &["foo.a.b.c"]);
Expand Down

0 comments on commit cba6797

Please sign in to comment.