Changeset 279


Ignore:
Timestamp:
09/08/09 08:32:03 (10 years ago)
Author:
b0rland_parpg
Message:

Ticket #67: Patch by b0rland

  • Moved GameObject? tests to a separate file and added more tests
  • Rewrote run_tests to automatically execute all tests from tests directory
  • Converted all tests into camelCase naming convention
Location:
trunk/game
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/run_tests.py

    r276 r279  
    55    return os.path.sep.join(path.split('/')) 
    66 
    7 _paths = ('../../engine/swigwrappers/python', '../../engine/extensions') 
     7_paths = ('../../engine/swigwrappers/python', '../../engine/extensions','tests') 
     8test_suite = unittest.TestSuite() 
     9 
    810for p in _paths: 
    911    if p not in sys.path: 
    1012        sys.path.append(_jp(p)) 
    1113 
    12 from tests.test_objects_base import * 
    13 from tests.test_crate import * 
     14for p in os.listdir("tests") : 
     15    if p[-3:] == ".py" : 
     16        test_suite.addTest(unittest.TestLoader().loadTestsFromName(p[:-3])) 
    1417 
    15 if __name__ == '__main__': 
    16     unittest.main() 
     18unittest.TextTestRunner(verbosity=2).run(test_suite) 
  • trunk/game/tests/test_crate.py

    r276 r279  
    99        self.crate2 = WoodenCrate(ID='crate02', locked=False) 
    1010 
    11     def test_creation(self): 
     11    def testCreation(self): 
    1212        self.assertEqual(self.crate.ID, 'crate01') 
    1313        self.assertEqual(self.crate.name, 'Wooden Crate') 
     
    2626    # can't test containing functionality...there are no containable objects 
    2727 
    28     def test_lockable(self): 
     28    def testLockable(self): 
    2929        self.crate2.lock() 
    3030        self.assertEqual(self.crate2.locked, True) 
  • trunk/game/tests/test_objects_base.py

    r276 r279  
    55 
    66class TestObjectsBase(unittest.TestCase): 
    7     def test_game_object(self): 
    8         test = GameObject (1, {'map':'img/test.png'}, 
    9                            1, 1, None, 'Test object', 'Description') 
    10         self.assertEqual(test.coords, (1, 1)) 
    11         self.assertEqual(test.X, 1) 
    12         self.assertEqual(test.Y, 1) 
    13         test.coords = (2,2) 
    14         self.assertEqual(test.X, 2.0) 
    15         self.assertEqual(test.Y, 2.0) 
    167 
    17     def test_wildcard(self): 
     8    def testWildcard(self): 
    189        class Wildcard (GameObject, Lockable, Container, Living, Scriptable, 
    1910                        CharStats, Wearable, Usable, Weapon, Destructable, 
Note: See TracChangeset for help on using the changeset viewer.