forked from AG_QGIS/Plugin_SN_Basis
Wrappe modular aufgebaut, Tests erfolgreich, Menüleiste und Werzeugleiste werden eingetragen (QT6 und QT5)- (Es fehlen noch Fachplugins, um zu prüfen, ob es auch wirklich in QGIS geht)
This commit is contained in:
@@ -11,18 +11,22 @@ import inspect
|
||||
import os
|
||||
import sys
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Pre-Bootstrap: Plugin-Root in sys.path eintragen
|
||||
# ---------------------------------------------------------
|
||||
|
||||
THIS_FILE = Path(__file__).resolve()
|
||||
PLUGIN_ROOT = THIS_FILE.parents[2]
|
||||
|
||||
# Minimaler Bootstrap, um sn_basis importierbar zu machen
|
||||
TEST_DIR = os.path.dirname(__file__)
|
||||
PLUGIN_ROOT = os.path.abspath(os.path.join(TEST_DIR, "..", ".."))
|
||||
if str(PLUGIN_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(PLUGIN_ROOT))
|
||||
|
||||
if PLUGIN_ROOT not in sys.path:
|
||||
sys.path.insert(0, PLUGIN_ROOT)
|
||||
|
||||
|
||||
from sn_basis.functions import syswrapper
|
||||
from sn_basis.functions import (
|
||||
get_plugin_root,
|
||||
add_to_sys_path,
|
||||
)
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Bootstrap: Plugin-Root in sys.path eintragen
|
||||
@@ -33,13 +37,12 @@ def bootstrap():
|
||||
Simuliert das QGIS-Plugin-Startverhalten:
|
||||
stellt sicher, dass sn_basis importierbar ist.
|
||||
"""
|
||||
plugin_root = syswrapper.get_plugin_root()
|
||||
syswrapper.add_to_sys_path(plugin_root)
|
||||
plugin_root = get_plugin_root()
|
||||
add_to_sys_path(plugin_root)
|
||||
|
||||
|
||||
bootstrap()
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Farben
|
||||
# ---------------------------------------------------------
|
||||
@@ -53,12 +56,14 @@ RESET = "\033[0m"
|
||||
|
||||
GLOBAL_TEST_COUNTER = 0
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Farbige TestResult-Klasse
|
||||
# ---------------------------------------------------------
|
||||
|
||||
class ColoredTestResult(unittest.TextTestResult):
|
||||
|
||||
_last_test_class: type | None = None
|
||||
|
||||
|
||||
def startTest(self, test):
|
||||
global GLOBAL_TEST_COUNTER
|
||||
@@ -93,16 +98,19 @@ class ColoredTestResult(unittest.TextTestResult):
|
||||
super().addSuccess(test)
|
||||
self.stream.write(f"{GREEN}OK{RESET}\n")
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Farbiger TestRunner
|
||||
# ---------------------------------------------------------
|
||||
|
||||
class ColoredTestRunner(unittest.TextTestRunner):
|
||||
resultclass = ColoredTestResult
|
||||
|
||||
def _makeResult(self):
|
||||
result = super()._makeResult()
|
||||
result = ColoredTestResult(
|
||||
self.stream,
|
||||
self.descriptions,
|
||||
self.verbosity,
|
||||
)
|
||||
|
||||
original_start_test = result.startTest
|
||||
|
||||
def patched_start_test(test):
|
||||
@@ -127,7 +135,7 @@ def main():
|
||||
f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S}{RESET}"
|
||||
)
|
||||
print("=" * 70 + "\n")
|
||||
|
||||
|
||||
loader = unittest.TestLoader()
|
||||
|
||||
suite = loader.discover(
|
||||
|
||||
Reference in New Issue
Block a user