Skip to content
Snippets Groups Projects
Commit e41fb28c authored by Radoslav Bodó's avatar Radoslav Bodó
Browse files

init

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #7692 failed
[flake8]
max-line-length = 150
.coverage
__pycache__/
venv/
---
image: debian:bookworm-slim
stages:
- code_quality
variables:
GIT_STRATEGY: clone
code_quality:
stage: code_quality
before_script:
- make install-dev
script:
- . venv/bin/activate && make coverage
- . venv/bin/activate && make lint
[FORMAT]
max-line-length=150
Makefile 0 → 100644
all: coverage lint
install-dev:
apt-get update
apt-get install -y python3-venv
python3 -m venv venv
. venv/bin/activate && pip install -r requirements.txt
test:
python3 -m pytest -v
coverage:
coverage run --source program -m pytest tests/ -x -vv
coverage report --show-missing --fail-under 100
lint:
python3 -m flake8 program.py tests
python3 -m pylint program.py tests
#!/usr/bin/env python3
"""
pytest basics
"""
def myfunc(a, b):
"""glorious function"""
return a + b
if __name__ == "__main__": # pragma: nocover
myfunc(1, 2)
# runtime
# nothing so far
# development
coverage
flake8
pylint
pytest
"""pytest-basics fixtures"""
import os
import shutil
from tempfile import mkdtemp
import pytest
@pytest.fixture
def tmpworkdir():
"""
self cleaning temporary workdir
pytest tmpdir fixture has issues https://github.com/pytest-dev/pytest/issues/1120
"""
cwd = os.getcwd()
tmpdir = mkdtemp(prefix='pytest-basics_')
os.chdir(tmpdir)
yield tmpdir
os.chdir(cwd)
shutil.rmtree(tmpdir)
"""tests"""
import os
import program
def test_myfunc():
"""test1"""
assert program.myfunc(1, 2) == 3
def test_workdir(tmpworkdir): # pylint: disable=unused-argument
"""test2"""
print(os.getcwd())
assert os.getcwd().startswith("/tmp/pytest-basics_")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment