Ejemplo n.º 1
0
    def _run_test(self, cluster, collect_to_remove, expected):
        logger, test_name = _getLogger(self)

        title = '==================== {} ===================='.format(test_name)
        logger.debug(title)

        logger.debug('- cluster: %s', cluster())
        logger.debug('- about to clean: %s', collect_to_remove(cluster()))
        logger.debug('- expected %s', repr(expected))

        cleaned = set()
        cleanup_func = cleanup(collect_to_remove, clean_action=cleaned.add)

        if type(expected) == CleanupError:
            try:
                cleanup_func(cluster())
                self.fail('CleanupError expected')
            except CleanupError as e:
                logger.debug('- exception thrown: %s', e)
                self.assertEqual(expected.errno, e.errno)
        else:
            cleanup_func(cluster())

            logger.debug('- cleaned %s', cleaned)
            self.assertEqual(expected, cleaned)

        logger.debug(''.join('=' for _ in range(len(title))))
Ejemplo n.º 2
0
    def _run_test(self, cluster, collect_to_remove, expected):
        logger, test_name = _getLogger(self)

        title = '==================== {} ===================='.format(
            test_name)
        logger.debug(title)

        logger.debug('- cluster: %s', cluster())
        logger.debug('- about to clean: %s', collect_to_remove(cluster()))
        logger.debug('- expected %s', repr(expected))

        cleaned = set()
        cleanup_func = cleanup(collect_to_remove, clean_action=cleaned.add)

        if type(expected) == CleanupError:
            try:
                cleanup_func(cluster())
                self.fail('CleanupError expected')
            except CleanupError as e:
                logger.debug('- exception thrown: %s', e)
                self.assertEqual(expected.errno, e.errno)
        else:
            cleanup_func(cluster())

            logger.debug('- cleaned %s', cleaned)
            self.assertEqual(expected, cleaned)

        logger.debug(''.join('=' for _ in range(len(title))))
Ejemplo n.º 3
0
def cleanup_files(where, selected, dry_run=True, strict_walk=True):
    find_files(
        duplicates,
        where,
        action = cleanup(selected, clean_action=dry_run_clean if dry_run else None),
        strict_walk = strict_walk
    )
Ejemplo n.º 4
0
def cleanup_files(where, selected, dry_run=True, strict_walk=True):
    find_files(duplicates,
               where,
               action=cleanup(selected,
                              clean_action=dry_run_clean if dry_run else None),
               strict_walk=strict_walk)