summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_frozendict.py19
-rw-r--r--tests/test_implements.py51
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/test_frozendict.py b/tests/test_frozendict.py
new file mode 100644
index 0000000..3f8045d
--- /dev/null
+++ b/tests/test_frozendict.py
@@ -0,0 +1,19 @@
1from foundry.utils import frozendict
2from nose.tools import raises
3
4
5class TestFrozenDict(object):
6
7 def setup(self):
8 self.inputs = { 'foo': 'bar' }
9 self.dict_ = frozendict(self.inputs)
10
11 @raises(AttributeError)
12 def test_should_not_allow_assignment(self):
13 self.dict_['bar'] = 'baz'
14
15 def test_should_use_precomputed_hash(self):
16 assert hash(self.dict_) == self.dict_._frozendict__hash
17
18 def test_should_set_slots(self):
19 assert self.dict_.__slots__ == self.inputs.keys()
diff --git a/tests/test_implements.py b/tests/test_implements.py
new file mode 100644
index 0000000..48ffe4b
--- /dev/null
+++ b/tests/test_implements.py
@@ -0,0 +1,51 @@
1# vim: set filencoding=utf8
2"""
3Implements Decorator Tests
4
5@author: Mike Crute (mcrute@gmail.com)
6@organization: SoftGroup Interactive, Inc.
7@date: May 02, 2010
8"""
9
10
11from foundry.utils import implements
12from nose.tools import raises
13
14
15class MyInterface(object):
16
17 def get(self, foo):
18 pass
19
20 def set(self, bar, baz=None):
21 pass
22
23 def remove(self, *args, **kwargs):
24 pass
25
26
27def test_conforming_should_not_fail():
28 @implements(MyInterface, debug=True)
29 class Conforming(object):
30
31 def get(self, foo):
32 pass
33
34 def set(self, bar, baz=None):
35 pass
36
37 def remove(self, *args, **kwargs):
38 pass
39
40
41@raises(AssertionError)
42def test_non_conforming_should_fail():
43 @implements(MyInterface, debug=True)
44 class NonConforming(object):
45 pass
46
47
48def test_non_debug_should_do_nothing():
49 @implements(MyInterface)
50 class NonConforming(object):
51 pass