Changeset 284


Ignore:
Timestamp:
09/16/09 07:15:53 (10 years ago)
Author:
b0rland_parpg
Message:

Ticket #67: patch by b0rland

  • Added GPL headers to test scripts
  • Added descriptions to test methods
  • Added the try/except guard to Openable class where it accesses GameObject?'s method (being overcautious)
  • Added tests for Openable class
  • Renamed some more test classes to match the naming convention
Location:
trunk/game
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/run_tests.py

    r279 r284  
    11#!/usr/bin/python 
     2 
     3#   This program is free software: you can redistribute it and/or modify 
     4#   it under the terms of the GNU General Public License as published by 
     5#   the Free Software Foundation, either version 3 of the License, or 
     6#   (at your option) any later version. 
     7 
     8#   This program is distributed in the hope that it will be useful, 
     9#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11#   GNU General Public License for more details. 
     12 
     13#   You should have received a copy of the GNU General Public License 
     14#   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     15 
     16 
    217import sys, os, unittest 
    318 
  • trunk/game/scripts/objects/base.py

    r276 r284  
    123123        """Opens the object, and runs an 'onOpen' script, if present""" 
    124124        self.is_open = True 
    125         if self.trueAttr ('scriptable'): 
    126             self.runScript('onOpen') 
     125        try: 
     126            if self.trueAttr ('scriptable'): 
     127                self.runScript('onOpen') 
     128        except AttributeError : 
     129            pass 
    127130             
    128131    def close(self): 
    129132        """Opens the object, and runs an 'onClose' script, if present""" 
    130133        self.is_open = False 
    131         if self.trueAttr ('scriptable'): 
    132             self.runScript('onClose')              
    133          
     134        try: 
     135            if self.trueAttr ('scriptable'): 
     136                self.runScript('onClose') 
     137        except AttributeError : 
     138            pass 
    134139class Lockable (Openable): 
    135140    """Allows objects to be locked""" 
  • trunk/game/tests/test_console.py

    r281 r284  
     1#!/usr/bin/python 
     2 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
     17 
     18 
    119import unittest 
    220from scripts.console import Console 
  • trunk/game/tests/test_crate.py

    r279 r284  
    11#!/usr/bin/python 
     2 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    217 
    318import unittest 
    419from scripts.objects.containers import WoodenCrate 
    520 
    6 class WoodenCrateTest(unittest.TestCase): 
     21class TestWoodenCrate(unittest.TestCase): 
    722    def setUp(self): 
    823        self.crate = WoodenCrate(ID='crate01') 
     
    1025 
    1126    def testCreation(self): 
     27        """ Test the WoodenCrate creation""" 
    1228        self.assertEqual(self.crate.ID, 'crate01') 
    1329        self.assertEqual(self.crate.name, 'Wooden Crate') 
     
    2743 
    2844    def testLockable(self): 
     45        """ Test the WoodenCrate lockability""" 
    2946        self.crate2.lock() 
    3047        self.assertEqual(self.crate2.locked, True) 
  • trunk/game/tests/test_game_object.py

    r279 r284  
    1 # To change this template, choose Tools | Templates 
    2 # and open the template in the editor. 
     1#!/usr/bin/python 
     2 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    317 
    418import unittest 
    519from scripts.objects.base import GameObject 
    620 
    7 class GameObjectTest(unittest.TestCase): 
     21class TestGameObject(unittest.TestCase): 
    822    def setUp(self): 
    923        self.game_object=GameObject (1, {'map':'img/test.png'}, 
     
    1529 
    1630    def testCoords(self): 
     31        """ Test GameObject coordinates manipulation""" 
     32 
    1733        self.assertEqual(self.game_object.coords, (1, 1)) 
    1834        self.assertEqual(self.game_object.X, 1) 
     
    2339 
    2440    def testTrueAttr(self): 
     41        """ Test GameObject trueAttr functionality""" 
     42         
    2543        self.game_object.is_test=True 
    2644        self.game_object.is_test2=False 
     
    3048 
    3149    def testRepr(self): 
     50        """ Test GameObject textual representation""" 
     51 
    3252        self.assertEqual(repr(self.game_object), "<Test object:1>") 
    3353 
  • trunk/game/tests/test_objects_base.py

    r279 r284  
    1 #!python 
     1#!/usr/bin/python 
     2 
     3#   This file is part of PARPG. 
     4 
     5#   PARPG is free software: you can redistribute it and/or modify 
     6#   it under the terms of the GNU General Public License as published by 
     7#   the Free Software Foundation, either version 3 of the License, or 
     8#   (at your option) any later version. 
     9 
     10#   PARPG is distributed in the hope that it will be useful, 
     11#   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13#   GNU General Public License for more details. 
     14 
     15#   You should have received a copy of the GNU General Public License 
     16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    217 
    318import unittest 
Note: See TracChangeset for help on using the changeset viewer.