Skip to content

Commit 7c0c147

Browse files
committed
[bazel] Run python unit tests with bazel
1 parent 6681d50 commit 7c0c147

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

py/BUILD.bazel

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ py_library(
2121
":get-attribute",
2222
":is-displayed",
2323
],
24+
deps = [
25+
"//third_party/py:urllib3",
26+
],
2427
imports = ["."],
2528
visibility = ["//visibility:public"],
2629
)
@@ -30,10 +33,20 @@ py_test(
3033
size = "small",
3134
srcs = glob([
3235
"test/unit/**/*.py",
33-
]) + [ "test/run_pytest.py" ],
34-
main = "test/run_pytest.py",
36+
]) + [ "test/runner/run_pytest.py" ],
37+
main = "test/runner/run_pytest.py",
3538
deps = [
3639
":main",
40+
"//third_party/py:pytest",
3741
],
3842
legacy_create_init = False,
3943
)
44+
45+
py_binary(
46+
name = "untar",
47+
visibility = ["//visibility:public"],
48+
srcs = [
49+
"untar.py",
50+
],
51+
legacy_create_init = False,
52+
)

py/test/run_pytest.py renamed to py/test/runner/run_pytest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
with open("pytest.ini", "w") as ini_file:
44
ini_file.write("[pytest]\n")
55
ini_file.write("addopts = -r=a\n")
6+
ini_file.write("rootdir = py")
67
ini_file.write("python_files = test_*.py *_tests.py\n")
78

89
raise SystemExit(pytest.main())

third_party/py/BUILD.bazel

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1+
load("//py:defs.bzl", "py_import")
12

3+
py_import(
4+
name = "py",
5+
wheel = "py-1.4.32-py2.py3-none-any.whl",
6+
)
7+
8+
py_import(
9+
name = "pytest",
10+
wheel = "pytest-3.0.3-py2.py3-none-any.whl",
11+
deps = [
12+
":py",
13+
":pytest-mock",
14+
],
15+
visibility = [
16+
"//visibility:public",
17+
]
18+
)
19+
20+
py_import(
21+
name = "pytest-mock",
22+
wheel = "pytest_mock-1.5.0-py2.py3-none-any.whl",
23+
)
24+
25+
py_import(
26+
name = "urllib3",
27+
wheel = "urllib3-1.23-py2.py3-none-any.whl",
28+
visibility = [
29+
"//visibility:public",
30+
]
31+
)

0 commit comments

Comments
 (0)