Changeset 370 for trunk/game/tests


Ignore:
Timestamp:
11/05/09 19:27:51 (10 years ago)
Author:
eliedebrauwer
Message:

Ticket #147. Patch by eliedebrauwer: Added more verbosity in error reporting, updated unittest to be more verbose as well, added standalone validator utility. fixes[s:trac, t:147]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/tests/test_dialogue.py

    r369 r370  
    2020import unittest 
    2121from scripts.dialogue import DialogueEngine 
    22 from scripts.dialoguevalidator import DialogueValidator 
     22from scripts.dialoguevalidator import DialogueValidator, DialogueFormatException 
    2323 
    2424class TestDialogue(unittest.TestCase): 
     
    140140        val = DialogueValidator() 
    141141        diag_dir = os.path.join(os.path.curdir, "dialogue"); 
     142        num_faulty_files = 0 
     143         
     144        # Test the dialogue files  
    142145        for dialogue in os.listdir(diag_dir): 
    143146            fname = os.path.join(diag_dir, dialogue) 
    144147            if os.path.isfile(fname) : 
    145                 val.validateDialogue(fname,".") 
     148                try: 
     149                    assert(val.validateDialogueFromFile(fname,".")) 
     150                except DialogueFormatException as dfe: 
     151                    print "\nError found in file: ", fname  
     152                    print "Error was: %s" % (dfe) 
     153                    num_faulty_files += 1 
     154         
     155        # Test the internal tree  
     156        #try: 
     157        #    assert(val.validateDialogue(self.tree,".")) 
     158        #except DialogueFormatException as dfe: 
     159        #    print "\nError found in inernal tree: ", fname  
     160        #    print "Error was: %s" % (dfe) 
     161        #    num_faulty_files += 1             
     162         
     163        assert(num_faulty_files == 0) 
    146164   
    147165if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.