def testRotate(self): """Check `LaunchpadLogFile.rotate`. Check if the log file is rotated as expected and only the specified number to rotated files are kept, also that the specified number of compressed files are created. """ log_file = LaunchpadLogFile('test.log', self.temp_dir, maxRotatedFiles=2, compressLast=1) # Monkey-patch DailyLogFile.suffix to be time independent. self.local_index = 0 def testSuffix(tupledate): self.local_index += 1 return str(self.local_index) log_file.suffix = testSuffix log_file.rotate() self.assertEqual(['test.log', 'test.log.1'], self.listTestFiles()) log_file.rotate() self.assertEqual(['test.log', 'test.log.1.bz2', 'test.log.2'], self.listTestFiles()) log_file.rotate() self.assertEqual(['test.log', 'test.log.2.bz2', 'test.log.3'], self.listTestFiles())
def testRotate(self): """Check `LaunchpadLogFile.rotate`. Check if the log file is rotated as expected and only the specified number to rotated files are kept, also that the specified number of compressed files are created. """ log_file = LaunchpadLogFile( 'test.log', self.temp_dir, maxRotatedFiles=2, compressLast=1) # Monkey-patch DailyLogFile.suffix to be time independent. self.local_index = 0 def testSuffix(tupledate): self.local_index += 1 return str(self.local_index) log_file.suffix = testSuffix log_file.rotate() self.assertEqual( ['test.log', 'test.log.1'], self.listTestFiles()) log_file.rotate() self.assertEqual( ['test.log', 'test.log.1.bz2', 'test.log.2'], self.listTestFiles()) log_file.rotate() self.assertEqual( ['test.log', 'test.log.2.bz2', 'test.log.3'], self.listTestFiles())