From 4546631ed7cc59f3e66a1902b28930f955b2b03f Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 17 Mar 2024 01:24:00 +0100 Subject: [PATCH] Re-structure for unittest usage. --- .pylintrc | 4 ++-- days.py => plomtask/days.py | 0 task.py => plomtask/task.py | 2 +- scripts/pre-commit | 10 +++++++--- tests/test_days.py | 11 +++++++++++ 5 files changed, 21 insertions(+), 6 deletions(-) rename days.py => plomtask/days.py (100%) rename task.py => plomtask/task.py (99%) create mode 100644 tests/test_days.py diff --git a/.pylintrc b/.pylintrc index 45e0778..8033983 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,3 +1,3 @@ [BASIC] - -good-names-rgx=do_(GET|POST)(_[a-z]+)? +init-hook='import sys; sys.path.append(".")' +good-names-rgxs=do_(GET|POST)(_[a-z]+)?,test_[A-Z]+ diff --git a/days.py b/plomtask/days.py similarity index 100% rename from days.py rename to plomtask/days.py diff --git a/task.py b/plomtask/task.py similarity index 99% rename from task.py rename to plomtask/task.py index 9631434..49ca883 100755 --- a/task.py +++ b/plomtask/task.py @@ -5,7 +5,7 @@ from http.server import HTTPServer from urllib.parse import urlparse from os.path import split as path_split from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader -from days import Day +from .days import Day HTTP_PORT = 8082 TEMPLATES_DIR = 'templates' diff --git a/scripts/pre-commit b/scripts/pre-commit index 9400e92..813455c 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -1,6 +1,10 @@ #!/bin/sh set -e -python3 -m mypy *.py -python3 -m flake8 *.py -python3 -m pylint *.py +python3 -m mypy plomtask/*.py +python3 -m flake8 plomtask/*.py +python3 -m pylint plomtask/*.py +python3 -m mypy tests/*.py +python3 -m flake8 tests/*.py +python3 -m pylint tests/*.py +python3 -m unittest tests/*.py exit 0 diff --git a/tests/test_days.py b/tests/test_days.py new file mode 100644 index 0000000..c799f06 --- /dev/null +++ b/tests/test_days.py @@ -0,0 +1,11 @@ +"""Test days module.""" +from unittest import TestCase +from plomtask.days import Day + + +class DayTests(TestCase): + """Tests for testing the days module.""" + + def test_Day_weekday(self): + """Test Day.weekday.""" + self.assertEqual(Day('2024-03-17').weekday, 'Sunday') -- 2.30.2