def testFullDir(self, persist=False): """ Test that rotator does it's basic functionality. """ # Prepare prefix = "prefix" stubContent = ('"Multiple exclamation marks", ' 'he went on, shaking his head, ' '"are a sure sign of a diseased mind."') # (C) Terry Pratchet - Small Gods with namedTemporaryDir() as dir: gen = 10 expectedDirContent = [] for i in range(gen): fname = "%s.txt.%d" % (prefix, i + 1) expectedDirContent.append("%s.txt.%d" % (prefix, i + 1)) f = open(os.path.join(dir, fname), "wb") f.write(stubContent) f.flush() f.close() # Rotate misc.rotateFiles(dir, prefix, gen, persist=persist) # Test result currentDirContent = os.listdir(dir) expectedDirContent.sort() currentDirContent.sort() self.assertEquals(currentDirContent, expectedDirContent)
def testEmptyDir(self, persist=False): """ Test that when given an empty dir the rotator works correctly. """ prefix = "prefix" with namedTemporaryDir() as dir: misc.rotateFiles(dir, prefix, 0, persist=persist)
def testEmptyDir(self, persist=False): """ Test that when given an empty dir the rotator works correctly. """ prefix = "prefix" dir = tempfile.mkdtemp() misc.rotateFiles(dir, prefix, 0, persist=persist) os.rmdir(dir)