-
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.
set up a hello world unit test and Github Actions
- Loading branch information
hchen_codon
committed
Mar 12, 2024
1 parent
f5afd7d
commit 5141561
Showing
4 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Python Application Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest | ||
pip install -e . | ||
- name: Test with pytest | ||
run: | | ||
pytest ./tests/ |
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,12 @@ | ||
# /repo/phuego/cli_app.py | ||
import click | ||
|
||
@click.command() | ||
@click.option('--greeting', default='Hello', help='Greeting phrase.') | ||
@click.option('--name', default='World', help='Name to greet.') | ||
def greet(greeting, name): | ||
"""Simple program that greets NAME for a total of COUNT times.""" | ||
click.echo(f"{greeting}, {name}!") | ||
|
||
if __name__ == '__main__': | ||
greet() |
Empty file.
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,9 @@ | ||
# /repo/tests/test_hello_world.py | ||
from click.testing import CliRunner | ||
from phuego.cli_app import greet | ||
|
||
def test_greet(): | ||
runner = CliRunner() | ||
result = runner.invoke(greet, ['--name', 'World']) | ||
assert result.exit_code == 0 | ||
assert 'Hello, World!' in result.output |