示例#1
0
def main():
    """
    The main function call of the application. From here we configure the 
    logger, load our config file, and demonstrate using the C extension modules
    """

    configLog.config(__name__)

    # Logger levels: debug, info, warning, error, critical
    Logger.info('App started')

    # Grab the config file
    config = configparser.ConfigParser()
    if config.read(IniFileName):
        Logger.info('%s loaded successfully' % (IniFileName))
    else:
        Logger.error('%s failed to load' % (IniFileName))
        raise Exception("Cannot load %s" % IniFileName)

    # Show we have loaded our config, and we can grab bits from it
    Logger.debug(config["section1"]["pi"])
    Logger.debug(config["trans"]["human"])

    # Demonstrate left bit-shift with our C extension
    Logger.debug(demo.LeftShift(74, 2))

    # Get some nibbles, we hungry
    Logger.debug(demo.GetHighNibble(90))

    # Use some code in another module
    anothermodule.afunctionname()

    Logger.info('App finished')
示例#2
0
 def test_Float_2(self):
     with self.assertRaises(TypeError):
         demo.LeftShift(6, 6.8)
示例#3
0
 def test_Float_1(self):
     with self.assertRaises(TypeError):
         demo.LeftShift(1.5, 53)
示例#4
0
 def test_Negative_2(self):
     with self.assertRaises(OverflowError):
         demo.LeftShift(2, -6)
示例#5
0
 def test_OverFlow_2(self):
     with self.assertRaises(OverflowError):
         demo.LeftShift(2, 0x1ffffffff)
示例#6
0
 def test_Incorrect(self):
     # 7 << 2 = 28
     self.assertNotEqual(demo.LeftShift(7, 2), 12)
示例#7
0
 def test_Correct(self):
     self.assertEqual(demo.LeftShift(2, 2), 8)