changeset 16:b92f660f2461

Begin a test infrastructure: using unittest and flake8. Need a requirements-dev.txt now also.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 20 Apr 2026 13:31:42 +0200
parents db0171f62e5a
children 251898f2f0c7
files MANIFEST.in Makefile requirements-dev.txt tests/_tsetup.py tests/test_fr.py
diffstat 5 files changed, 62 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MANIFEST.in	Mon Apr 20 09:06:51 2026 +0200
+++ b/MANIFEST.in	Mon Apr 20 13:31:42 2026 +0200
@@ -1,1 +1,3 @@
-include requirements.txt
+include .hg* *.txt
+graft tests
+global-exclude *.pyc *.pyo
--- a/Makefile	Mon Apr 20 09:06:51 2026 +0200
+++ b/Makefile	Mon Apr 20 13:31:42 2026 +0200
@@ -4,11 +4,13 @@
 # SPDX-License-Identifier: MIT
 # :-
 
-.PHONY: help clean distclean dist build
+.PHONY: help all clean distclean dist build tests flake8
 
 help:
 	@echo Targets: help, clean, distclean, dist, build
 
+all: tests flake8
+
 build:
 	python -m build
 
@@ -20,3 +22,10 @@
 clean:
 	rm -rf __arch/
 	find . -name '*.pyc' -delete
+
+tests:
+	-python -m unittest discover -s tests
+
+flake8:
+	-flake8 pygments_lexer_pseudocode2
+	-flake8 tests
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/requirements-dev.txt	Mon Apr 20 13:31:42 2026 +0200
@@ -0,0 +1,2 @@
+-r requirements.txt
+flake8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/_tsetup.py	Mon Apr 20 13:31:42 2026 +0200
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+# :-
+# SPDX-FileCopyrightText: © 2026 Franz Glasner
+# SPDX-License-Identifier: MIT
+r"""Automatic unittest context configuration.
+
+Side-effects of import configure the test environment!
+
+"""
+
+import logging
+import os
+import sys
+
+
+sys.path.insert(
+    0,
+    os.path.abspath(
+        os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))))
+
+
+TESTDATADIR = os.path.join(
+    os.path.abspath(os.path.dirname(__file__)),
+    "data")
+
+
+# Setup logging for the unittests: use a known fixed format w/o time
+logging.captureWarnings(True)
+logging.basicConfig(
+    level=logging.DEBUG,
+    style='%',
+    format="[%(name)s][%(filename)s:%(lineno)d:%(funcName)s][%(levelname)s] %(message)s")        # noqa: E501 (line too long)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_fr.py	Mon Apr 20 13:31:42 2026 +0200
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+# :-
+# SPDX-FileCopyrightText: © 2026 Franz Glasner
+# SPDX-License-Identifier: MIT
+# :-
+
+import _tsetup    # noqa:F401 (imported but unused)
+
+import unittest
+
+
+if __name__ == "__main__":
+    unittest.main()
+
+