Ejemplo n.º 1
0
 def testCanFindFilesInRootFolder(self):
     pythonSet = antglob.AntPatternSet()
     pythonSet.include('**/*.py, **/*.rst')
     pythonSet.exclude('**/*.pyc, **/*.pyo')
     filePathCount = 0
     _log.info(u'find pattern set: %s', pythonSet)
     for path in pythonSet.find(self._testFolderPath):
         _log.info(u'  found: %s', path)
         self.assertFalse(antglob.isFolderPath(path), 'path must not be folder: %r' % path)
         suffix = os.path.splitext(path)[1]
         self.assertTrue(suffix in ('.py', '.rst'))
         filePathCount += 1
     self.assertTrue(filePathCount)
Ejemplo n.º 2
0
    def testCanFindEmptyFolder(self):
        pythonSet = antglob.AntPatternSet()

        # Create a test folder containing exactly 1 empty sub folder.
        testFolderPath = tempfile.mkdtemp(prefix='test_antpattern_')
        emptyFolderPath = os.path.join(testFolderPath, 'emptyFolder')
        os.mkdir(emptyFolderPath)

        pathCount = 0
        for path in pythonSet.find(testFolderPath, True):
            _log.info(u'  found: %s', path)
            pathCount += 1
            self.assertTrue(antglob.isFolderPath(path), 'path must be a folder: %r' % path)
        self.assertEqual(pathCount, 1)
Ejemplo n.º 3
0
 def testCanFindFilesAndfFolders(self):
     pythonSet = antglob.AntPatternSet()
     pythonSet.include('**/*.py, **/*.rst')
     pythonSet.exclude('**/*.pyc, **/*.pyo')
     filePathCount = 0
     folderPathCount = 0
     _log.info(u'find pattern set: %s', pythonSet)
     for path in pythonSet.find(self._testFolderPath, True):
         _log.info(u'  found: %s', path)
         if antglob.isFolderPath(path):
             folderPathCount += 1
         else:
             suffix = os.path.splitext(path)[1]
             self.assertTrue(suffix in ('.py', '.rst'))
             filePathCount += 1
     self.assertTrue(filePathCount)
     self.assertTrue(folderPathCount)