From 1b316b32a63cf872e96731ed573fcb733abfc07b Mon Sep 17 00:00:00 2001 From: Florentin Labelle <florentin.labelle@student-cs.fr> Date: Sun, 9 Oct 2022 17:59:24 +0200 Subject: [PATCH] Add linting CI --- .gitlab-ci.yml | 27 +++++++++++++++++++++++++++ calculator/operators.py | 8 ++++++++ 2 files changed, 35 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..4cb279b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,27 @@ +image: python:3.10 + +stages: + - dependencies + - lint + +download_dependencies: + stage: dependencies + before_script: + - venv .venv + - source .venv/bin/activate + script: + - pip install -r requirements.txt + artifacts: + paths: + - .venv + +pylint: + stage: lint + dependencies: + - download_dependencies + needs: + - download_dependencies + before_script: + - pip install pylint + script: + - pylint calculator --fail-on=error diff --git a/calculator/operators.py b/calculator/operators.py index a353a01..c5534cf 100644 --- a/calculator/operators.py +++ b/calculator/operators.py @@ -22,3 +22,11 @@ STANDARD_OPERATORS = { '*': Operator('×', 2, lambda a, b: a * b), '/': Operator('/', 2, lambda a, b: a / b), } + +def test_operator(): + """ + Test the Operator class. + """ + operator = Operator('%', 1, lambda a, b: a % b) + assert repr(operator) == '%' + assert operator(15, 4) == 3 -- GitLab