def tearDown(self): mock.unmockAll() if getattr(server, 'dbConnection', None): server.dbConnection.close() server.dbConnection = None testhelp.TestCase.tearDown(self) try: fixtureCache.delRepos() self.cfg and util.rmtree(self.cfg.dataPath) except OSError: pass
def testStopDaemon(self): raise testsuite.SkipTestException('Fails in bamboo') daemonClass = self.generateDaemonClass() util.mkdirChain(self.workDir + '/var/log') util.mkdirChain(self.workDir + '/var/lock') d = daemonClass() rv, txt = self.captureOutput(d.main, ['./daemontest', 'start']) assert (not rv) mock.mock(os, 'kill') mock.mock(time, 'sleep') mock.mockMethod(d.error) err, txt = self.captureOutput(d.main, ['./daemontest', 'stop'], _returnException=True) msg = d.error._mock.popCall()[0][0] assert ('Failed to kill foobar (pid ' in msg) mock.unmockAll() self.captureOutput(d.main, ['./daemontest', 'stop'])
def testStopDaemon(self): raise testsuite.SkipTestException('Fails in bamboo') daemonClass = self.generateDaemonClass() util.mkdirChain(self.workDir + '/var/log') util.mkdirChain(self.workDir + '/var/lock') d = daemonClass() rv, txt = self.captureOutput(d.main, ['./daemontest', 'start']) assert(not rv) mock.mock(os, 'kill') mock.mock(time, 'sleep') mock.mockMethod(d.error) err, txt = self.captureOutput(d.main, ['./daemontest', 'stop'], _returnException=True) msg = d.error._mock.popCall()[0][0] assert('Failed to kill foobar (pid ' in msg) mock.unmockAll() self.captureOutput(d.main, ['./daemontest', 'stop'])
def testRpmToCpioXz(self): # ensure that we are testing the /usr/bin/xz path here realExists = os.path.exists def access_xz(*args): if args[0].endswith("/unlzma"): return False return realExists(*args) mock.mock(os.path, "exists", access_xz) f = os.popen( "%s %s/gnome-main-menu-0.9.10-26.x86_64.rpm | cpio -t --quiet" % (self.rpm2cpio, resources.get_archive()) ) l = f.readlines() assert len(l) > 0 self.assertEqual(l[0], "./etc/gconf/schemas/application-browser.schemas\n") mock.unmockAll()
def testRpmToCpioXz(self): # ensure that we are testing the /usr/bin/xz path here realExists = os.path.exists def access_xz(*args): if args[0].endswith('/unlzma'): return False return realExists(*args) mock.mock(os.path, 'exists', access_xz) f = os.popen( "%s %s/gnome-main-menu-0.9.10-26.x86_64.rpm | cpio -t --quiet" % (self.rpm2cpio, resources.get_archive())) l = f.readlines() assert (len(l) > 0) self.assertEqual(l[0], './etc/gconf/schemas/application-browser.schemas\n') mock.unmockAll()
def run(self, *args, **kw): from conary.lib import util fdCount = util.countOpenFileDescriptors() if fdCount != len(self.openFds): self.openFds = self._openFdSet() prePid = os.getpid() try: unittest.TestCase.run(self, *args, **kw) finally: # Make sure some test didn't accidentally fork the # testsuite. postPid = os.getpid() if prePid != postPid: sys.stderr.write("\n*** CHILD RE-ENTERED TESTSUITE ***\n") sys.stderr.write("A forked process was allowed to return to " "the testsuite handler, probably due\nto an exception. " "Find it and kill it!\n") sys.stderr.write("PID was: %d now: %d\n" % (prePid, postPid)) os._exit(2) self.unmock() mock.unmockAll() # ask gc to run to see if we can avoid "leaked -1 file descriptors" gc.collect() fdCount = util.countOpenFileDescriptors() if False and fdCount != len(self.openFds): try: methodName = self.__testMethodName except AttributeError: methodName = self._testMethodName sys.stderr.write("\nTest %s.%s leaked %s file descriptors\n" % (self.__module__, methodName, fdCount - len(self.openFds))) newOpenFds = self._openFdSet() for (fd, contents) in newOpenFds - self.openFds: if contents and ((fd, contents) not in self.openFds): print '%s: %s' % (fd, contents) self.openFds = newOpenFds
def testNoPlatDefLocalRepo(self): # simulate that a different platform source label was found mock.unmockAll() mock.mock(platformmgr.PlatformDefCache, '_getPlatDef') platformmgr.PlatformDefCache._getPlatDef._mock.raiseErrorOnAccess( proddef.ProductDefinitionTroveNotFoundError) platformmgr.PlatformDefCache._getPlatDef._mock.setDefaultReturn(None) mock.mock(reposmgr.RepositoryManager, 'getIncomingMirrorUrlByLabel') reposmgr.RepositoryManager.getIncomingMirrorUrlByLabel._mock.setReturn( 'localhost@rpath:plat-1', 'localhost@rpath:plat-1') mock.mock(reposdb.RepositoryManager, 'getServerProxy') reposdb.RepositoryManager.getServerProxy._mock.setReturn( self.cclient.repos.c.cache['localhost'], 'localhost', 'localhost@rpath:plat-1', None, [None]) mgr = self.db.platformMgr.platformCache.getReposMgr() mgr.db.isOffline._mock.setDefaultReturn(False) self.db.platformMgr.getPlatforms() self.assertEquals( len(platformmgr.PlatformDefCache._getPlatDef._mock.calls), 3)
def tearDown(self): RpathToolsTest.tearDown(self) mock.unmockAll()
def tearDown(self): if self.mintDb: self.mintDb.close() mock.unmockAll()
def tearDown(self): mock.unmockAll()
def tearDown(self): mock.unmockAll() testcase.TestCase.tearDown(self)
def tearDown(self): mock.unmockAll() testcase.TestCaseWithWorkDir.tearDown(self) for handler in logging.root.handlers: logging.root.removeHandler(handler) logging.root.setLevel(logging.WARNING)
def tearDown(self): unittest.TestCase.tearDown(self) mock.unmockAll()