예제 #1
0
 def test_directoryPattern(self):
     """Tests if pattern containing directory separator does not match any file (this is intended behavior!)."""
     directory = self.dataBasePath
     pathList = list(
         wawCommons.absoluteFilePaths(
             directory, [os.path.join("directory1", "*.test")]))
     assert len(pathList) == 0
예제 #2
0
 def test_ifFileInDirectoryIsNotFound(self):
     """Tests if particular file is not found by absoluteFilePaths when it's not contained in supplied directory."""
     directory = os.path.join(self.dataBasePath, 'directory1')
     anotherDirectory = os.path.join(self.dataBasePath, 'directory2')
     pathList = list(wawCommons.absoluteFilePaths(directory))
     testFile = os.path.abspath(os.path.join(anotherDirectory,
                                             "file2.test"))
     assert testFile not in pathList
예제 #3
0
    def test_pattternMatchMultipleFiles(self):
        """Tests if pattern in absoluteFilePaths can match multiple files."""
        directory = os.path.join(self.dataBasePath, 'directory1')
        pathList = list(wawCommons.absoluteFilePaths(directory, ["*"]))

        testFile1 = os.path.abspath(os.path.join(directory, "file1.test"))
        assert testFile1 in pathList
        testFile2 = os.path.abspath(os.path.join(directory, "fileA.ext"))
        assert testFile2 in pathList
예제 #4
0
    def test_filePatternsInDirectory(self):
        """Tests if files returned from absoluteFilePaths can be filtered by patterns parameter."""
        directory = os.path.join(self.dataBasePath, 'directory1')
        pathList = list(wawCommons.absoluteFilePaths(directory, ["*.test"]))

        testFile1 = os.path.abspath(os.path.join(directory, "file1.test"))
        assert testFile1 in pathList
        testFile2 = os.path.abspath(os.path.join(directory, "fileA.ext"))
        assert testFile2 not in pathList
예제 #5
0
    def test_ifFileInDirectoryIsFound(self):
        """Tests if particular files are found by absoluteFilePaths when it's contained in supplied directory."""
        directory = os.path.join(self.dataBasePath, 'directory1')
        pathList = list(wawCommons.absoluteFilePaths(directory))

        testFile1 = os.path.abspath(os.path.join(directory, "file1.test"))
        assert testFile1 in pathList
        testFile2 = os.path.abspath(os.path.join(directory, "fileA.ext"))
        assert testFile2 in pathList
예제 #6
0
    def test_questionMarkInPattern(self):
        """Tests if absoluteFilePaths can correctly handle question mark in pattern."""
        directory = os.path.join(self.dataBasePath, 'directory1')
        pathList = list(wawCommons.absoluteFilePaths(directory, ["file?.*"]))

        testFile1 = os.path.abspath(os.path.join(directory, "file1.test"))
        assert testFile1 in pathList
        testFile2 = os.path.abspath(os.path.join(directory, "fileA.ext"))
        assert testFile2 in pathList
예제 #7
0
    def test_multiplePattterns(self):
        """Tests if mutiple patterns in absoluteFilePaths behave like there is operator OR between them."""
        directory = os.path.join(self.dataBasePath, 'directory1')
        pathList = list(
            wawCommons.absoluteFilePaths(directory, ["*.test", "*"]))

        testFile1 = os.path.abspath(os.path.join(directory, "file1.test"))
        assert testFile1 in pathList
        testFile2 = os.path.abspath(os.path.join(directory, "fileA.ext"))
        assert testFile2 in pathList
예제 #8
0
 def test_emptyPatterns(self):
     """Tests if absoluteFilePaths returns no files when no patterns supplied."""
     directory = self.dataBasePath
     pathList = list(wawCommons.absoluteFilePaths(directory, []))
     assert len(pathList) == 0
예제 #9
0
 def test_nonExistentDirectory(self):
     """Tests if absoluteFilePaths can handle non-existent directory."""
     nonExistentDir = os.path.join(self.dataBasePath,
                                   'non_existent_dir_123456789/')
     pathList = list(wawCommons.absoluteFilePaths(nonExistentDir))
     assert len(pathList) == 0