--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixlpark.com
+@license: GPL3
+@summary: general used functions an objects used for unit tests on
+ the base python modules
+"""
+
+import os
+import sys
+import logging
+import argparse
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+# Own modules
+
+from pb_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 > 1:
+ root_log.setLevel(logging.DEBUG)
+ elif verbose:
+ root_log.setLevel(logging.INFO)
+
+ 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 AdminToolsTestcase(unittest.TestCase):
+
+ # -------------------------------------------------------------------------
+ def __init__(self, methodName='runTest', verbose=0):
+
+ self._verbose = int(verbose)
+
+ super(AdminToolsTestcase, self).__init__(methodName)
+
+ # -------------------------------------------------------------------------
+ @property
+ def verbose(self):
+ """The verbosity level."""
+ return getattr(self, '_verbose', 0)
+
+ # -------------------------------------------------------------------------
+ def setUp(self):
+
+ pass
+
+ # -------------------------------------------------------------------------
+ def tearDown(self):
+
+ pass
+
+# =============================================================================
+
+if __name__ == '__main__':
+
+ pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@license: GPL3
+@summary: test script (and module) for unit tests on ConfigDiffer
+ and ConfigFileDiffer classes
+"""
+
+import os
+import sys
+import logging
+import locale
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+from pb_base.common import pp
+from pb_base.common import bytes2human
+
+libdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+sys.path.insert(0, libdir)
+
+from general import AdminToolsTestcase, get_arg_verbose, init_root_logger
+
+locale.setlocale(locale.LC_ALL, '')
+
+APPNAME = 'test_differ'
+
+LOG = logging.getLogger(APPNAME)
+
+
+# =============================================================================
+class ConfigDifferTest(AdminToolsTestcase):
+
+ # -------------------------------------------------------------------------
+ def setUp(self):
+ self.appname = APPNAME
+
+ # -------------------------------------------------------------------------
+ def tearDown(self):
+ pass
+
+
+ # -------------------------------------------------------------------------
+ def test_import(self):
+
+ LOG.info("Testing import of pp_lib.differ ...")
+ import pp_lib.differ # noqa
+
+ LOG.info("Testing import of ConfigDiffer from pp_lib.differ ...")
+ from pp_lib.differ import ConfigDiffer # noqa
+
+ LOG.info("Testing import of ConfigFileDiffer from pp_lib.differ ...")
+ from pp_lib.differ import ConfigFileDiffer # noqa
+
+
+# =============================================================================
+
+
+if __name__ == '__main__':
+
+ verbose = get_arg_verbose()
+ if verbose is None:
+ verbose = 0
+ init_root_logger(verbose)
+
+ LOG.info("Starting tests ...")
+
+ loader = unittest.TestLoader()
+ suite = unittest.TestSuite()
+
+ suite.addTest(ConfigDifferTest('test_import', verbose))
+ #suite.addTest(ConfigDifferTest('test_init_config_differ', verbose))
+ #suite.addTest(ConfigDifferTest('test_init_config_file_differ', verbose))
+
+ runner = unittest.TextTestRunner(verbosity=verbose)
+
+ result = runner.run(suite)
+
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4