class BaseTest(unittest.TestCase): def setUp(self): print('Running setUp') if os.path.exists(os.path.join('..','test.cfg')): self.bar=NurdBar(os.path.join('..','test.cfg')) else: self.bar=NurdBar('test.cfg') global log self.log=logging.getLogger(__name__) self.log.debug('nurdbar instantiated') self.bar.drop_tables() self.log.debug('Dropped tables') self.bar.create_tables() self.log.debug('Created tables') self.bar.fill_tables() self.log.debug('Finished BaseTest setUp') def tearDown(self): self.log.debug('Running tearDown') try: self.bar.session.commit() self.bar.session.flush() except Exception: self.log.error("Error occured during commit:\n%s"%traceback.format_exc()) self.bar.session.rollback() raise self.bar.drop_tables() for event in events.__all__: event.clearHandlers() self.log.debug('Finished BaseTest tearDown')
def setUp(self): print('Running setUp') if os.path.exists(os.path.join('..','test.cfg')): self.bar=NurdBar(os.path.join('..','test.cfg')) else: self.bar=NurdBar('test.cfg') global log self.log=logging.getLogger(__name__) self.log.debug('nurdbar instantiated') self.bar.drop_tables() self.log.debug('Dropped tables') self.bar.create_tables() self.log.debug('Created tables') self.bar.fill_tables() self.log.debug('Finished BaseTest setUp')
#set the working dir and pyton path to the parent directory, so we can find the config file and nurdbar module. import sys import os import subprocess import time parent_path=os.path.join(os.path.abspath(os.path.dirname(__file__)),'..') sys.path.append(parent_path) os.chdir(parent_path) configfile = 'config.cfg' from nurdbar import NurdBar bar=NurdBar(configfile) bar.drop_tables() bar.create_tables() bar.fill_tables() bar.addMember('USR1','root')
#set the working dir and pyton path to the parent directory, so we can find the config file and nurdbar module. import sys import os import subprocess import time parent_path=os.path.join(os.path.abspath(os.path.dirname(__file__)),'..') sys.path.append(parent_path) os.chdir(parent_path) configfile = 'config.cfg' from nurdbar import NurdBar bar=NurdBar(configfile) bar.addBarcodeDesc('CASH','Cash')