--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank@brehm-online.com
+@copyright: © 2021 Frank Brehm, Digitas Pixelpark GmbH Berlin
+@license: LGPL3
+@summary: general used functions an objects used for unit tests on
+ the pp-admintools
+"""
+
+import os
+import sys
+import logging
+import argparse
+
+from pathlib import Path
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+import six
+
+# Own modules
+from fb_logging.colored import ColoredFormatter
+
+# =============================================================================
+
+LOG = logging.getLogger(__name__)
+
+
+# =============================================================================
+def get_arg_verbose():
+
+ arg_parser = argparse.ArgumentParser()
+
+ arg_parser = argparse.ArgumentParser()
+ arg_parser.add_argument(
+ "-v", "--verbose", action="count",
+ dest='verbose', help='Increase the verbosity level')
+ args = arg_parser.parse_args()
+
+ return args.verbose
+
+
+# =============================================================================
+def init_root_logger(verbose=0):
+
+ root_log = logging.getLogger()
+ root_log.setLevel(logging.WARNING)
+ if verbose:
+ root_log.setLevel(logging.INFO)
+ if verbose > 1:
+ root_log.setLevel(logging.DEBUG)
+
+ appname = os.path.basename(sys.argv[0])
+ format_str = appname + ': '
+ if verbose:
+ if verbose > 1:
+ format_str += '%(name)s(%(lineno)d) %(funcName)s() '
+ else:
+ format_str += '%(name)s '
+ format_str += '%(levelname)s - %(message)s'
+ formatter = None
+ formatter = ColoredFormatter(format_str)
+
+ # create log handler for console output
+ lh_console = logging.StreamHandler(sys.stderr)
+ if verbose:
+ lh_console.setLevel(logging.DEBUG)
+ else:
+ lh_console.setLevel(logging.INFO)
+ lh_console.setFormatter(formatter)
+
+ root_log.addHandler(lh_console)
+
+
+# =============================================================================
+class PpAdminToolsTestcase(unittest.TestCase):
+
+ # -------------------------------------------------------------------------
+ def __init__(self, methodName='runTest', verbose=0):
+
+ self._verbose = int(verbose)
+
+ appname = os.path.basename(sys.argv[0]).replace('.py', '')
+ self._appname = appname
+
+ super(PpAdminToolsTestcase, self).__init__(methodName)
+
+ self.curdir = Path(os.path.dirname(os.path.abspath(__file__)))
+
+ self.open_args = {}
+ if six.PY3:
+ self.open_args['encoding'] = 'utf-8'
+ self.open_args['errors'] = 'surrogateescape'
+
+ self.server_version = '4.1.10-mocked'
+
+ # -------------------------------------------------------------------------
+ @property
+ def verbose(self):
+ """The verbosity level."""
+ return getattr(self, '_verbose', 0)
+
+ # -------------------------------------------------------------------------
+ @property
+ def appname(self):
+ """The name of the current running application."""
+ return self._appname
+
+ # -------------------------------------------------------------------------
+ def setUp(self):
+ pass
+
+ # -------------------------------------------------------------------------
+ def tearDown(self):
+ pass
+
+
+# =============================================================================
+if __name__ == '__main__':
+
+ pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4