File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,21 @@ py_test(
22
22
"@pypi_pytest//:pkg" ,
23
23
],
24
24
)
25
+
26
+ py_test (
27
+ name = "nested/pytest" ,
28
+ srcs = [
29
+ "foo_test.py" ,
30
+ ":__test__" ,
31
+ ],
32
+ env_inherit = ["FOO" ],
33
+ imports = ["../.." ],
34
+ main = ":__test__.py" ,
35
+ package_collisions = "warning" ,
36
+ deps = [
37
+ ":__test__" ,
38
+ "@pypi_ftfy//:pkg" ,
39
+ "@pypi_neptune//:pkg" ,
40
+ "@pypi_pytest//:pkg" ,
41
+ ],
42
+ )
Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ def _py_binary_rule_impl(ctx):
32
32
# each segment from site-packages in the venv to the root of the runfiles tree.
33
33
# Five .. will get us back to the root of the venv:
34
34
# {name}.runfiles/.{name}.venv/lib/python{version}/site-packages/first_party.pth
35
- escape = "/" .join (([".." ] * 4 ))
35
+ # If the target is defined with a slash, it adds to the level of nesting
36
+ target_depth = len (ctx .label .name .split ("/" )) - 1
37
+ escape = "/" .join (([".." ] * (4 + target_depth )))
36
38
37
39
# A few imports rely on being able to reference the root of the runfiles tree as a Python module,
38
40
# the common case here being the @rules_python//python/runfiles target that adds the runfiles helper,
You can’t perform that action at this time.
0 commit comments