source: trunk/game/tests/test_objects_base.py @ 284

Revision 284, 2.3 KB checked in by b0rland_parpg, 10 years ago (diff)

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
Line 
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
18import unittest
19from scripts.objects.base import *
20
21class TestObjectsBase(unittest.TestCase):
22
23    def testWildcard(self):
24        class Wildcard (GameObject, Lockable, Container, Living, Scriptable,
25                        CharStats, Wearable, Usable, Weapon, Destructable,
26                        Trappable, Carryable, ):
27            def __init__ (self, ID, *args, **kwargs):
28                self.name = 'All-purpose carry-all'
29                self.text = 'What is this? I dont know'
30                GameObject.  __init__( self, ID, **kwargs )
31                Lockable.    __init__( self, **kwargs )
32                Container.   __init__( self, **kwargs )
33                Living.      __init__( self, **kwargs )
34                Scriptable.  __init__( self, **kwargs )
35                CharStats.   __init__( self, **kwargs )
36                Wearable.    __init__( self, **kwargs )
37                Usable.      __init__( self, **kwargs )
38                Weapon.      __init__( self, **kwargs )
39                Destructable.__init__( self, **kwargs )
40                Trappable.   __init__( self, **kwargs )
41                Carryable.   __init__( self, **kwargs )
42        wc = Wildcard (2)
43
44        # TODO: need to fill the rest of these tests out
45
46        attrs = dict(
47            is_openable = True,
48            is_open = True,
49            is_lockable = True,
50            locked = True,
51            is_carryable = True,
52            weight = 1.0,
53            is_container = True,
54            items = [],
55            is_living = True,
56            is_scriptable = True
57        )
58
59        for attr in attrs:
60            self.assertEqual(getattr(wc, attr), attrs[attr])
Note: See TracBrowser for help on using the repository browser.