Skip to content

Commit 0afccc2

Browse files
committed
Added tests and workflows
1 parent 7b45df1 commit 0afccc2

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

.github/workflows/python-app.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python application
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- main
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python 3.8
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: 3.8
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install flake8==3.8.4 pytest
29+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
- name: Lint with flake8
31+
run: |
32+
python setup.py lint
33+
- name: Test with pytest
34+
run: |
35+
python setup.py test
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types:
9+
- created
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: '3.8'
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install setuptools wheel twine
24+
- name: Build and publish
25+
env:
26+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
27+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
28+
run: |
29+
python setup.py sdist bdist_wheel
30+
twine upload dist/*

tests/__init__.py

Whitespace-only changes.

tests/test_convert.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from table2ascii import table2ascii as t2a
2+
3+
4+
def test_normal():
5+
text = t2a(
6+
["#", "G", "H", "R", "S"],
7+
[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
8+
["SUM", "130", "140", "135", "130"],
9+
)
10+
assert text == (
11+
"╔═════╦═══════════════════════╗\n"
12+
"║ # ║ G H R S ║\n"
13+
"╟─────╫───────────────────────╢\n"
14+
"║ 1 ║ 30 40 35 30 ║\n"
15+
"║ 2 ║ 30 40 35 30 ║\n"
16+
"╟─────╫───────────────────────╢\n"
17+
"║ SUM ║ 130 140 135 130 ║\n"
18+
"╚═════╩═══════════════════════╝"
19+
)

0 commit comments

Comments
 (0)