Skip to content

Add pytest_test support to rules_python. - #243

Closed
pstradomski wants to merge 6 commits into
bazel-contrib:masterfrom
pstradomski:master
Closed

pstradomski wants to merge 6 commits into
bazel-contrib:masterfrom
pstradomski:master

Conversation

@pstradomski

Copy link
Copy Markdown
Contributor

@edbaunton

Copy link
Copy Markdown
Contributor

Is this something that could be reviewed and merged some time soon? We would love to use pytest with Bazel!

@ali5h

ali5h commented Jan 15, 2020 •

Copy link
Copy Markdown

i personally don't think this should be part of rules_python. With a simple macro you can achieve this, check this as an example https://github.com/ali5h/rules_pip/blob/master/defs.bzl

@thundergolfer

thundergolfer commented Jan 15, 2020 •

Copy link
Copy Markdown

We already use PyTest with Bazel. It works with the standard py_test rule if you add the following snippet to the file run as main.

import pytest
import os
import sys 

...

if __name__ == "__main__":
    dir_path = os.path.dirname(os.path.realpath(__file__))
    sys.exit(pytest.main([dir_path, "-W", "ignore::DeprecationWarning"]))

Compared with other issues we have in our Python-Bazel codebase, this is a minor annoyance.

@pstradomski

Copy link
Copy Markdown
Contributor Author

Withdrawing as it seems there's no consensus this is the right approach.

@pstradomski pstradomski closed this May 3, 2020
@peloton-mqiu

peloton-mqiu commented Sep 28, 2020 •

Copy link
Copy Markdown

https://github.com/ali5h/rules_pip/blob/master/defs.bzl#L139

Hi @ali5h ,
is the link you shared still points to the line you originally intended?
master seems to have advanced, probably you are referring to this rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytest support

6 participants