My bazel py_test rule seems to be able to import files in the same folder for which there was no dependency declared. Is there a way to prevent this? I am running bazel 3.7.2 on linux. Here is an example:
# Note that foo_test doesn't declare :foo as a dependency
$ cat BUILD
py_library(
name = "foo",
srcs = ["foo.py"],
)
py_test(
name = "foo_test",
srcs = ["foo_test.py"],
)
$ cat foo.py
def foo():
print("hello")
# However, I can still import and use the library
$ cat foo_test.py
import foo
foo.foo()
$ bazel-3.7.2-linux-x86_64 test :foo_test
<snip>
//:foo_test PASSED in 0.3s
Is there a configuration option that would prevent the foo_test
rule from implicitly picking up foo.py
?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…