Skip to content

Commit

Permalink
Add py_test example.
Browse files Browse the repository at this point in the history
  • Loading branch information
kku1993 committed Jul 29, 2020
1 parent 3670b5c commit e4f3987
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
14 changes: 14 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ py_binary(
python_version = "PY3",
)

py_test(
name = "main_test",
srcs = ["main_test.py"],
deps = [
requirement("attrs"),
requirement("more-itertools"),
requirement("packaging"),
requirement("pluggy"),
requirement("py"),
requirement("pytest"),
requirement("wcwidth"),
],
)

####################
# Docker Image
####################
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Host python version is 3.6.9
Successfully imported psycopg2-binary!
```

# py_test demo

```
bazel test //:main_test
```

# Docker Image Demo

The image we're using is `python3:3.8.3-slim-buster`, which matches the python
Expand Down
12 changes: 12 additions & 0 deletions main_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import platform
import pytest
import sys

class TestPythonVersion:
def test_version(self):
assert('bazel-out/k8-fastbuild/bin/main_test.runfiles/python_interpreter/python_bin' in sys.executable)
assert(platform.python_version() == "3.8.3")

if __name__ == "__main__":
import pytest
raise SystemExit(pytest.main([__file__]))
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
attrs==19.3.0
more-itertools==8.2.0
packaging==20.3
pluggy==0.13.1
psycopg2-binary==2.8.5
py==1.8.1
pytest==5.4.1
wcwidth==0.1.9

0 comments on commit e4f3987

Please sign in to comment.