def add_log(self, job_id, name, attempt): if attempt > 1: name += '_retry%d' % (attempt - 1) filename = os.path.join(self.logdir, name + '.log') log = Logfile(name, filename, self.mode, self.delete) log.started() self.logs[job_id].append(log) return log
class LogfileTest(LogTest): CORRELATE = Logfile def setUp(self): self.tempdir = mkdtemp() self.logfile = os.path.join(self.tempdir, 'test.log') self.errorfile = self.logfile + '.error' self.log = Logfile('testme', self.logfile) def tearDown(self): rmtree(self.tempdir) def testConstructor(self): self.assertEqual('testme', self.log.get_name()) self.assertEqual('', str(self.log)) self.assertFalse(os.path.exists(self.logfile)) self.assertFalse(os.path.exists(self.errorfile)) def testStarted(self): LogTest.testStarted(self) self.assertTrue(os.path.exists(self.logfile)) self.assertFalse(os.path.exists(self.errorfile)) def testAborted(self): LogTest.testAborted(self) self.assertTrue(os.path.exists(self.logfile)) self.assertTrue(os.path.exists(self.errorfile)) def testSucceeded(self): LogTest.testSucceeded(self) self.assertTrue(os.path.exists(self.logfile)) self.assertFalse(os.path.exists(self.errorfile))
class LogfileTest(LogTest): CORRELATE = Logfile def setUp(self): self.tempdir = mkdtemp() self.logfile = os.path.join(self.tempdir, 'test.log') self.errorfile = self.logfile + '.error' self.log = Logfile('testme', self.logfile) def tearDown(self): rmtree(self.tempdir) def testConstructor(self): self.assertEqual('testme', self.log.get_name()) self.assertEqual('', str(self.log)) self.failIf(os.path.exists(self.logfile)) self.failIf(os.path.exists(self.errorfile)) def testStarted(self): LogTest.testStarted(self) self.assert_(os.path.exists(self.logfile)) self.failIf(os.path.exists(self.errorfile)) def testAborted(self): LogTest.testAborted(self) self.assert_(os.path.exists(self.logfile)) self.assert_(os.path.exists(self.errorfile)) def testSucceeded(self): LogTest.testSucceeded(self) self.assert_(os.path.exists(self.logfile)) self.failIf(os.path.exists(self.errorfile))
def setUp(self): self.tempdir = mkdtemp() self.logfile = os.path.join(self.tempdir, 'test.log') self.errorfile = self.logfile + '.error' self.log = Logfile('testme', self.logfile)