Skip to content

Commit a84071f

Browse files
committed
Fix exec_properties for py_test
Fixes #461
1 parent 6ad4667 commit a84071f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

examples/pytest/BUILD.bazel

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ py_test(
1313
"fixtures/*.json",
1414
]),
1515
env_inherit = ["FOO"],
16+
exec_properties = {
17+
"test.foo": "bar",
18+
},
1619
imports = ["../.."],
1720
package_collisions = "warning",
1821
pytest_main = True,

py/defs.bzl

+5
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ py_image_layer = _py_image_layer
6060
resolutions = _resolutions
6161

6262
def _py_binary_or_test(name, rule, srcs, main, deps = [], resolutions = {}, **kwargs):
63+
exec_properties = kwargs.pop("exec_properties", {})
64+
non_test_exec_properties = {k: v for k, v in exec_properties.items() if not k.startswith("test.")}
65+
6366
# Compatibility with rules_python, see docs in py_executable.bzl
6467
main_target = "{}.find_main".format(name)
6568
determine_main(
6669
name = main_target,
6770
target_name = name,
6871
main = main,
6972
srcs = srcs,
73+
exec_properties = non_test_exec_properties,
7074
**propagate_common_rule_attributes(kwargs)
7175
)
7276

@@ -79,6 +83,7 @@ def _py_binary_or_test(name, rule, srcs, main, deps = [], resolutions = {}, **kw
7983
deps = deps,
8084
resolutions = resolutions,
8185
package_collisions = package_collisions,
86+
exec_properties = exec_properties,
8287
**kwargs
8388
)
8489

0 commit comments

Comments
 (0)