Commits

John Chandler committed c8f61a4

Added hierarchy subdirectory test

  • Participants
  • Parent commits cc7b85e

Comments (0)

Files changed (2)

qadpid/hierarchy.py

 import os
 
 class PHPHierarchyCreator( object ):
-    """ Hierarchy Creator for PHP files """
-    hierarchy = {}
+    """ Hierarchy Creator for PHP files
+        Not entirely sure about this yet - probably needs a redesign
+    """
+    def __init__( self ):
+        self.hierarchy = {}
 
     def add( self, directory ):
         """ Takes a (dirpath, dirs, files) tuple (e.g. as returned by os.walk)

tests/test_hierarchy.py

         creator = PHPHierarchyCreator()
         creator.add( ('.', [], ["foo.php", "bar.php"]) )
         
-        self.assertEquals( PHPHierarchyCreator().hierarchy, { "./foo.php": None, "./bar.php": None } )
+        self.assertEquals( creator.hierarchy, { "./foo.php": None, "./bar.php": None } )
+
+    def test_subdir( self ):
+        """ Tests result when we add a sub dir with PHP files """
+        creator = PHPHierarchyCreator()
+        creator.add( ('./wibble', [], ["foo.php", "bar.php"]) )
+        
+        self.assertEquals( creator.hierarchy, { "./wibble/foo.php": None, "./wibble/bar.php": None } )
+        
 
 
 if __name__ == "__main__":