def test_Logging_argparse_001_01(self):
        """Test if 'argparse' works with MythLog."""

        m = MythLog('simple_test')

        parser = argparse.ArgumentParser(prog="simple_test")

        # Add arbitrary option:
        parser.add_argument('--chanid',
                            action='store',
                            dest='chanid',
                            default=0,
                            help='Use chanid for manual operation')

        # load MYthTV's extension
        m.loadArgParse(parser)

        # unittest : first arguements are the test class or the verbosity flag
        test_args = []
        args_found = False
        for a in argv:
            if not args_found:
                args_found = a.startswith('test')
            else:
                test_args.append(a)

        args = parser.parse_args(test_args)

        # check the default mask:
        self.assertEqual(m._MASK, LOGMASK.GENERAL)

        # check if helptext contains 'siparser'
        h = m.helptext
        found = False
        for line in h.split("\n"):
            match = re.findall(r'siparser', line)
            if match:
                found = True
        self.assertEqual(found, True)
    def test_Logging_argparse_002_01(self):
        """Test if 'argparse' works with MythLog."""

        # set default values acc. source code
        m_dblog = True
        m_loglevel = LOGLEVEL.INFO
        m_verbose = LOGMASK.GENERAL
        m_logfile = stdout

        with add_log_flags():
            m = MythLog('simple_test')
            parser = argparse.ArgumentParser(prog="simple_test")

            # load MYthTV's extension
            m.loadArgParse(parser)

            # unittest : first arguements are the test class or the verbosity flag
            # filter out arguements for unittesting:
            test_args = add_log_flags.additional_args

            # according 'add_log_flags', test_args should be:
            #  ['--nodblog', '--loglevel', 'debug', '--verbose', 'all', '--logfile', '/tmp/my_logfile']

            args = parser.parse_args(test_args)
            #print(test_args)
            #print(args)

            # check the options provided by 'additional_args':
            m_dblog = m._DBLOG
            m_loglevel = m._LEVEL
            m_verbose = m._MASK
            m_logfile = m._LOGFILE

        self.assertEqual(m_dblog, False)
        self.assertEqual(m_loglevel, LOGLEVEL.DEBUG)
        self.assertEqual(m_verbose, LOGMASK.ALL)
        self.assertTrue(os.path.exists("/tmp/my_logfile"))