Skip to content

Commit

Permalink
Add tests for CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Feb 3, 2024
1 parent de679bf commit e77c2be
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ format:
ruff format
ruff check --fix

test:
python -m pytest -n auto -v tests

clean:
rm -rf build dist *.egg-info

publish: clean
build: clean
python -m build --sdist --wheel

upload: build
python -m twine upload dist/samuel-*

publish: build upload
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ dependencies = [
"fastapi",
"loguru",
"onnxruntime",
"Pillow",
"uvicorn",
]
dynamic = ["readme", "version"]

[project.optional-dependencies]
test = [
"build",
"mypy",
"types-Pillow",
"pytest",
"pytest-xdist",
"ruff",
"twine",
]
Expand Down
15 changes: 15 additions & 0 deletions tests/test___main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import io
import os
import shlex
import subprocess

import PIL.Image

here = os.path.dirname(os.path.abspath(__file__))


def test_run():
cmd = f"samuel run efficient-sam:10m --image {here}/../examples/_images/dogs.jpg"
output = subprocess.check_output(shlex.split(cmd))
image = PIL.Image.open(io.BytesIO(output))
assert image.size == (2560, 1600)

0 comments on commit e77c2be

Please sign in to comment.