Exemple #1
0
 def test_generator(self):
     """ Test with no parameters. """
     # find all paths
     paths = []
     for path in find_paths(BASEPATH):
         paths.append(path)
     self.assertEqual(22, len(paths))
     self.assertTrue(os.path.join(BASEPATH, 'dir1') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir1', 'subdirectory') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir2') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir3') in paths)
     self.assertTrue(os.path.join(BASEPATH, '.dir4') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'file1.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'file2.dat') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'file3.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo.gif') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo.png') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo_gs.gif') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo_gs.jpg') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo_gs.png') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'transparent_gs.png') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir1', 'subdirectory', 'sub.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir1', 'file4.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir1', 'file5.log') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir2', 'file6.log') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir2', 'file7.html') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir3', 'file8') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir3', '.file9') in paths)
Exemple #2
0
 def test_generator(self):
     """ Test with no parameters. """
     # find all paths
     paths = []
     for path in find_paths(BASEPATH):
         paths.append(path)
     self.assertEqual(22, len(paths))
     self.assertTrue(os.path.join(BASEPATH, 'dir1') in paths)
     self.assertTrue(
         os.path.join(BASEPATH, 'dir1', 'subdirectory') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir2') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir3') in paths)
     self.assertTrue(os.path.join(BASEPATH, '.dir4') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'file1.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'file2.dat') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'file3.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo.gif') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo.png') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo_gs.gif') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo_gs.jpg') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'python_logo_gs.png') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'transparent_gs.png') in paths)
     self.assertTrue(
         os.path.join(BASEPATH, 'dir1', 'subdirectory', 'sub.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir1', 'file4.txt') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir1', 'file5.log') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir2', 'file6.log') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir2', 'file7.html') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir3', 'file8') in paths)
     self.assertTrue(os.path.join(BASEPATH, 'dir3', '.file9') in paths)
Exemple #3
0
def build_finder(path, filter, ignore):
    '''Construct a path finder for the specified `path` and with the specified
    `filter`. Hidden directories are ignored by default.'''
    if os.path.isfile(path):
        return (path,)
    return find_paths(path, filter=filter, ignore=ignore)
Exemple #4
0
#
# Copyright 2009 keyes.ie
#
# License: http://jkeyes.mit-license.org/
#

import os
import unittest

from radon.pathfinder import find_paths
from radon.pathfinder import walk_and_filter
from radon.pathfinder.filters import *

BASEPATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
pathfind = lambda *a, **kw: list(find_paths(*a, **kw))

class FindTest(unittest.TestCase):

    def test_just_dirs(self):
        """ Test just_dirs parameter."""
        # only find directories
        paths = pathfind(BASEPATH, just_dirs=True)
        self.assertEqual(5, len(paths))
        self.assertTrue(os.path.join(BASEPATH, 'dir1') in paths)
        self.assertTrue(os.path.join(BASEPATH, 'dir1', 'subdirectory') in paths)
        self.assertTrue(os.path.join(BASEPATH, 'dir2') in paths)
        self.assertTrue(os.path.join(BASEPATH, 'dir3') in paths)
        self.assertTrue(os.path.join(BASEPATH, '.dir4') in paths)

        # use Filter.find
        paths_2 = DirectoryFilter().find(BASEPATH)
Exemple #5
0
def build_finder(path, filter, ignore):
    '''Construct a path finder for the specified `path` and with the specified
    `filter`. Hidden directories are ignored by default.'''
    if os.path.isfile(path):
        return (path, )
    return find_paths(path, filter=filter, ignore=ignore)
Exemple #6
0
#
# Copyright 2009 keyes.ie
#
# License: http://jkeyes.mit-license.org/
#

import os
import unittest

from radon.pathfinder import find_paths
from radon.pathfinder import walk_and_filter
from radon.pathfinder.filters import *

BASEPATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
pathfind = lambda *a, **kw: list(find_paths(*a, **kw))


class FindTest(unittest.TestCase):
    def test_just_dirs(self):
        """ Test just_dirs parameter."""
        # only find directories
        paths = pathfind(BASEPATH, just_dirs=True)
        self.assertEqual(5, len(paths))
        self.assertTrue(os.path.join(BASEPATH, 'dir1') in paths)
        self.assertTrue(
            os.path.join(BASEPATH, 'dir1', 'subdirectory') in paths)
        self.assertTrue(os.path.join(BASEPATH, 'dir2') in paths)
        self.assertTrue(os.path.join(BASEPATH, 'dir3') in paths)
        self.assertTrue(os.path.join(BASEPATH, '.dir4') in paths)

        # use Filter.find