Skip to content

caseyduquettesc/rules_python_pytest

Repository files navigation

Bazel rules for python_pytest

Bazel rules to run your Python unit tests with pytest.

pytest support in rules_python is not provided out of the box, see bazel-contrib/rules_python#240 and bazel-contrib/rules_python#464. Progress on the feature request seems to have stagnated so I've gone ahead and put at least something in the public domain until rules_python offers it.

Features:

  • Run unit tests with pytest
  • Supports test filtering with Bazel's --test_filter= option

Installation

From the release you wish to use: https://github.com/caseyduquettesc/rules_python_pytest/releases copy the WORKSPACE snippet into your WORKSPACE file or the bazel_dep if you use bzlmod.

Usage

load("@rules_python_pytest//python_pytest:defs.bzl", "py_pytest_test")

py_pytest_test(
    name = "test_w_pytest",
    size = "small",
    srcs = ["test.py"],
    deps = [
      # TODO Add this for the user
      requirement("pytest"),
    ],
)

To use test sharding, also add requirement("pytest-shard") to deps.

Disclaimer

I rely on this myself and will accept issue reports and contributions, however this only has a simple smoke test and isn't documented terribly well. I will maintain this, however the expectation is that this will eventually be rolled into rules_python and at that point these rules will be deprecated.

About

Bazel rules to run Python tests with pytest

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy