Skip to content

Commit

Permalink
add test for relative paths breaking out of current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
sandbubbles committed Oct 5, 2024
1 parent bc7d569 commit 64ed8c3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/functional/syntax/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,30 @@ def foo():
{"top.vy": top, "subdir0/lib0.vy": lib0, "subdir0/subdir1/lib1.vy": lib1}
)
compiler.compile_code(top, input_bundle=input_bundle)

def test_relative_paths_stay_in_current_directory(make_input_bundle):
top = """
from subdir import b as b
@external
def foo():
b.foo()
"""

a = """
def foo():
pass
"""

b = """
from . import a as a
def foo():
a.foo()
"""

input_bundle = make_input_bundle(
{"top.vy": top, "a.vy": a, "subdir/b.vy": b }
)

with pytest.raises(ModuleNotFound):
compiler.compile_code(top, input_bundle=input_bundle)

0 comments on commit 64ed8c3

Please sign in to comment.