Skip to content

Commit

Permalink
fix(bazel): use py_test from rules_python in py_test_module_list
Browse files Browse the repository at this point in the history
Signed-off-by: Cameron Smith <cameron.ray.smith@gmail.com>
  • Loading branch information
cameronraysmith committed Jan 18, 2024
1 parent b661bff commit fffb0d6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions bazel/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@ bazel macros for python
"""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_python//python:defs.bzl", "py_test")

def py_test_module_list(files, size, deps, extra_srcs=[], name_suffix="", **kwargs):


def py_test_module_list(files, size, deps, args=[], extra_srcs=[], name_suffix="", **kwargs):
"""
py_test_module_list creates a py_test for each file in files.
"""
for file in files:
name = paths.split_extension(file)[0] + name_suffix
if name == file:
name = name + "_test"
native.py_test(
# native.py_test(
py_test(
name = name,
size = size,
main = file,
srcs = extra_srcs + [file],
args = [
"-rA",
"-v",
"--disable-warnings",
] + args,
deps = deps,
**kwargs
)
Expand All @@ -27,20 +36,22 @@ def xdoctest(files, name="xdoctest", deps=[], srcs=[], data=[], args=[], size="m
"""
files = native.glob(include=files, exclude=["__init__.py"])

native.py_test(
# native.py_test(
py_test(
name = name,
srcs = ["//bazel:pytest_wrapper.py"] + srcs,
main = "//bazel:pytest_wrapper.py",
size = size,
args = [
"-rA",
"-v",
"--disable-warnings",
"--xdoctest",
"-c=$(location //bazel:conftest.py)",
] + args + ["$(location :%s)" % file for file in files],
data = ["//bazel:conftest.py"] + files + data,
python_version = "PY3",
srcs_version = "PY3",
# python_version = "PY3",
# srcs_version = "PY3",
tags = tags,
deps = deps,
**kwargs
Expand Down

0 comments on commit fffb0d6

Please sign in to comment.