init tests
This commit is contained in:
parent
696da72adb
commit
5884cbaf04
35
.coveragerc
Normal file
35
.coveragerc
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# .coveragerc to control coverage.py
|
||||||
|
[run]
|
||||||
|
branch = False
|
||||||
|
source = src
|
||||||
|
|
||||||
|
omit =
|
||||||
|
*/tests/*
|
||||||
|
*/assets/*
|
||||||
|
*/src/styles/*
|
||||||
|
*/__init__.py
|
||||||
|
|
||||||
|
disable_warnings = include-ignored
|
||||||
|
|
||||||
|
[report]
|
||||||
|
# Regexes for lines to exclude from consideration
|
||||||
|
exclude_lines =
|
||||||
|
# Have to re-enable the standard pragma
|
||||||
|
pragma: no cover
|
||||||
|
|
||||||
|
# Don't complain about missing debug-only code:
|
||||||
|
def __repr__
|
||||||
|
def __str__
|
||||||
|
def main
|
||||||
|
if self\.debug
|
||||||
|
|
||||||
|
# Don't complain if tests don't hit defensive assertion code:
|
||||||
|
raise AssertionError
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
# Don't complain if non-runnable code isn't run:
|
||||||
|
if 0:
|
||||||
|
if __name__ == .__main__.:
|
||||||
|
|
||||||
|
ignore_errors = True
|
||||||
|
show_missing = True
|
31
.github/ci.yml
vendored
Normal file
31
.github/ci.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: Python package
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [ "3.10" ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Display Python version
|
||||||
|
run: python -c "import sys; print(sys.version)"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements_server.txt
|
||||||
|
pip install -r requirements_dev.txt
|
||||||
|
- name: Log in with sourcery
|
||||||
|
run:
|
||||||
|
sourcery login --token ${{ secrets.SOURCERY_TOKEN }}
|
||||||
|
- name: Run pre-commit checks
|
||||||
|
run: pre-commit run --all-files -a
|
||||||
|
- name: Run tests
|
||||||
|
run: pytest
|
@ -28,6 +28,7 @@ exclude = [".bzr",
|
|||||||
".idea",
|
".idea",
|
||||||
".streamlit",
|
".streamlit",
|
||||||
]
|
]
|
||||||
|
extend-exclude = ["tests", "assets", "src/styles"]
|
||||||
per-file-ignores = { }
|
per-file-ignores = { }
|
||||||
|
|
||||||
# Allow unused variables when underscore-prefixed.
|
# Allow unused variables when underscore-prefixed.
|
||||||
|
4
requirements_dev.txt
Normal file
4
requirements_dev.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
pytest==7.3.0
|
||||||
|
ruff==0.0.261
|
||||||
|
pre_commit==3.2.2
|
||||||
|
pytest-cov==4.0.0
|
@ -20,5 +20,5 @@ def get_files_in_dir(path: Path) -> List[str]:
|
|||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
||||||
def get_random_img(my_list: list) -> str:
|
def get_random_img(img_names: list[str]) -> str:
|
||||||
return random.choice(my_list)
|
return random.choice(img_names)
|
||||||
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
6
tests/test_helpers.py
Normal file
6
tests/test_helpers.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from src.utils.helpers import get_random_img
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_random_img():
|
||||||
|
img_names = ["img/1.png", "img/2.png", "img/3.png"]
|
||||||
|
assert get_random_img(img_names) in img_names
|
Loading…
Reference in New Issue
Block a user