Skip to content

Commit ade07c2

Browse files
committed
Fix exec_properties for py_test
Fixes #461
1 parent 55fd502 commit ade07c2

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, data = [], 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

@@ -80,6 +84,7 @@ def _py_binary_or_test(name, rule, srcs, main, data = [], deps = [], resolutions
8084
deps = deps,
8185
resolutions = resolutions,
8286
package_collisions = package_collisions,
87+
exec_properties = exec_properties,
8388
**kwargs
8489
)
8590

0 commit comments

Comments
 (0)