Bugfixes and improved tests
This commit is contained in:
parent
eec9bca498
commit
542dccda10
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,7 +26,6 @@ share/python-wheels/
|
|||||||
.installed.cfg
|
.installed.cfg
|
||||||
*.egg
|
*.egg
|
||||||
MANIFEST
|
MANIFEST
|
||||||
.idea/
|
|
||||||
|
|
||||||
# PyInstaller
|
# PyInstaller
|
||||||
# Usually these files are written by a python script from a template
|
# Usually these files are written by a python script from a template
|
||||||
|
@ -45,6 +45,7 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_foreground_color(cls, color: Union[ForegroundColor, str]):
|
def set_foreground_color(cls, color: Union[ForegroundColor, str]):
|
||||||
|
|
||||||
if type(color) is str:
|
if type(color) is str:
|
||||||
cls._foreground_color = ForegroundColor[color]
|
cls._foreground_color = ForegroundColor[color]
|
||||||
else:
|
else:
|
||||||
@ -66,9 +67,6 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _output(cls, string: str, x: int = None, y: int = None, end='\n'):
|
def _output(cls, string: str, x: int = None, y: int = None, end='\n'):
|
||||||
if cls._disabled:
|
|
||||||
return
|
|
||||||
|
|
||||||
if cls._is_first_write:
|
if cls._is_first_write:
|
||||||
cls._is_first_write = False
|
cls._is_first_write = False
|
||||||
|
|
||||||
@ -98,15 +96,21 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def banner(cls, string: str):
|
def banner(cls, string: str):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
ascii_banner = pyfiglet.figlet_format(string)
|
ascii_banner = pyfiglet.figlet_format(string)
|
||||||
cls.write_line(ascii_banner)
|
cls.write_line(ascii_banner)
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def clear():
|
def clear(cls):
|
||||||
os.system('cls' if os.name == 'nt' else 'clear')
|
os.system('cls' if os.name == 'nt' else 'clear')
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def close():
|
def close(cls):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
Console.reset()
|
Console.reset()
|
||||||
Console.write('\n\n\nPress any key to continue...')
|
Console.write('\n\n\nPress any key to continue...')
|
||||||
Console.read_line()
|
Console.read_line()
|
||||||
@ -118,6 +122,9 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def error(cls, string: str, tb: str = None):
|
def error(cls, string: str, tb: str = None):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
cls.set_foreground_color('red')
|
cls.set_foreground_color('red')
|
||||||
if tb is not None:
|
if tb is not None:
|
||||||
cls.write_line(f'{string} -> {tb}')
|
cls.write_line(f'{string} -> {tb}')
|
||||||
@ -138,6 +145,9 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def read_line(cls, output: str = None) -> str:
|
def read_line(cls, output: str = None) -> str:
|
||||||
|
if cls._disabled:
|
||||||
|
return ''
|
||||||
|
|
||||||
if output is not None:
|
if output is not None:
|
||||||
cls.write(output)
|
cls.write(output)
|
||||||
|
|
||||||
@ -150,6 +160,9 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def table(cls, header: list[str], values: list[list[str]]):
|
def table(cls, header: list[str], values: list[list[str]]):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
table = tabulate(values, headers=header)
|
table = tabulate(values, headers=header)
|
||||||
|
|
||||||
Console.write_line(table)
|
Console.write_line(table)
|
||||||
@ -157,16 +170,25 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write(cls, *args):
|
def write(cls, *args):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
string = ' '.join(map(str, args))
|
string = ' '.join(map(str, args))
|
||||||
cls._output(string, end='')
|
cls._output(string, end='')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write_at(cls, x: int, y: int, *args):
|
def write_at(cls, x: int, y: int, *args):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
string = ' '.join(map(str, args))
|
string = ' '.join(map(str, args))
|
||||||
cls._output(string, x, y, end='')
|
cls._output(string, x, y, end='')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write_line(cls, *args):
|
def write_line(cls, *args):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
string = ' '.join(map(str, args))
|
string = ' '.join(map(str, args))
|
||||||
if not cls._is_first_write:
|
if not cls._is_first_write:
|
||||||
cls._output('')
|
cls._output('')
|
||||||
@ -174,6 +196,9 @@ class Console:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write_line_at(cls, x: int, y: int, *args):
|
def write_line_at(cls, x: int, y: int, *args):
|
||||||
|
if cls._disabled:
|
||||||
|
return
|
||||||
|
|
||||||
string = ' '.join(map(str, args))
|
string = ' '.join(map(str, args))
|
||||||
if not cls._is_first_write:
|
if not cls._is_first_write:
|
||||||
cls._output('', end='')
|
cls._output('', end='')
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
import unittest
|
|
||||||
from typing import Type
|
|
||||||
|
|
||||||
from tests.cases.service.provider_test import ProviderTest
|
|
||||||
from tests.cases.time.time_format_settings_test import TimeFormatSettingsTest
|
|
||||||
from tests.cases.utils.credential_manager_test import CredentialManagerTest
|
|
||||||
|
|
||||||
|
|
||||||
class Tester:
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self._suite = unittest.TestSuite()
|
|
||||||
self._cases: list[Type[unittest.TestCase]] = []
|
|
||||||
|
|
||||||
def _build_cases(self):
|
|
||||||
for case in self._cases:
|
|
||||||
case_functions = [method_name for method_name in dir(case) if callable(getattr(case, method_name)) and method_name.startswith('test_')]
|
|
||||||
for function in case_functions:
|
|
||||||
self._suite.addTest(case(function))
|
|
||||||
|
|
||||||
def create(self):
|
|
||||||
self._cases.append(ProviderTest)
|
|
||||||
self._cases.append(CredentialManagerTest)
|
|
||||||
self._cases.append(TimeFormatSettingsTest)
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
self._build_cases()
|
|
||||||
runner = unittest.TextTestRunner()
|
|
||||||
runner.run(self._suite)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
tester = Tester()
|
|
||||||
tester.create()
|
|
||||||
tester.start()
|
|
Loading…
Reference in New Issue
Block a user