[pywin32-checkins] pywin32/win32/test test_win32file.py,1.2,1.3
OLD project page for the Python extensions for Windows
                
                Brought to you by:
                
                    mhammond
                    
                
            
            
        
        
        
    | 
      
      
      From: Mark H. <mha...@us...> - 2004-06-12 13:26:10
      
     | 
| Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29328 Modified Files: test_win32file.py Log Message: Test FindFiles and FindFilesIterator Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_win32file.py 24 Oct 2003 01:50:15 -0000 1.2 --- test_win32file.py 12 Jun 2004 13:26:02 -0000 1.3 *************** *** 4,7 **** --- 4,9 ---- import os import tempfile + import sets + import shutil class TestSimpleOps(unittest.TestCase): *************** *** 109,112 **** --- 111,154 ---- h.Close() + class TestFindFiles(unittest.TestCase): + def testIter(self): + dir = os.path.join(os.getcwd(), "*") + files = win32file.FindFilesW(dir) + set1 = sets.Set() + set1.update(files) + set2 = sets.Set() + for file in win32file.FindFilesIterator(dir): + set2.add(file) + assert len(set2) > 5, "This directory has less than 5 files!?" + self.failUnlessEqual(set1, set2) + + def testBadDir(self): + dir = os.path.join(os.getcwd(), "a dir that doesnt exist", "*") + self.assertRaises(win32file.error, win32file.FindFilesIterator, dir) + + def testEmptySpec(self): + spec = os.path.join(os.getcwd(), "*.foo_bar") + num = 0 + for i in win32file.FindFilesIterator(spec): + print "Got", i + num += 1 + self.failUnlessEqual(0, num) + + def testEmptyDir(self): + test_path = os.path.join(win32api.GetTempPath(), "win32file_test_directory") + try: + shutil.rmtree(test_path) + except os.error: + pass + os.mkdir(test_path) + try: + num = 0 + for i in win32file.FindFilesIterator(os.path.join(test_path, "*")): + num += 1 + # Expecting "." and ".." only + self.failUnlessEqual(2, num) + finally: + shutil.rmtree(test_path) + if __name__ == '__main__': unittest.main() |