forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to create python test suites, and use it
This works in much the same way as the test suites for Java do, but with python.
- Loading branch information
Showing
3 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
load("//py/private:import.bzl", _py_import = "py_import") | ||
load("//py/private:pytest.bzl", _pytest_test = "pytest_test") | ||
load("//py/private:suite.bzl", _py_test_suite = "py_test_suite") | ||
|
||
py_import = _py_import | ||
pytest_test = _pytest_test | ||
py_import = _py_import | ||
py_test_suite = _py_test_suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
load("//py/private:pytest.bzl", "pytest_test") | ||
|
||
def _is_test(file): | ||
return file.startswith("test_") or file.endswith("_tests.py") | ||
|
||
def py_test_suite(name, srcs, size = None, deps = None, python_version = None, imports = None, visibility = None, **kwargs): | ||
library_name = "%s-test-lib" % name | ||
|
||
py_library( | ||
name = library_name, | ||
testonly = True, | ||
srcs = srcs, | ||
deps = deps, | ||
imports = imports, | ||
) | ||
|
||
tests = [] | ||
for src in srcs: | ||
if _is_test(src): | ||
test_name = "%s-%s" % (name, src) | ||
|
||
tests.append(test_name) | ||
|
||
pytest_test( | ||
name = test_name, | ||
size = size, | ||
srcs = [src], | ||
deps = [library_name], | ||
python_version = python_version, | ||
**kwargs, | ||
) | ||
native.test_suite( | ||
name = name, | ||
tests = tests, | ||
visibility = visibility, | ||
) |