summaryrefslogtreecommitdiff
path: root/tests/test_implements.py
blob: 48ffe4b00e5ec356b481c584388d50c8da4107f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# vim: set filencoding=utf8
"""
Implements Decorator Tests

@author: Mike Crute (mcrute@gmail.com)
@organization: SoftGroup Interactive, Inc.
@date: May 02, 2010
"""


from foundry.utils import implements
from nose.tools import raises


class MyInterface(object):

    def get(self, foo):
        pass

    def set(self, bar, baz=None):
        pass

    def remove(self, *args, **kwargs):
        pass


def test_conforming_should_not_fail():
    @implements(MyInterface, debug=True)
    class Conforming(object):

        def get(self, foo):
            pass

        def set(self, bar, baz=None):
            pass

        def remove(self, *args, **kwargs):
            pass


@raises(AssertionError)
def test_non_conforming_should_fail():
    @implements(MyInterface, debug=True)
    class NonConforming(object):
        pass


def test_non_debug_should_do_nothing():
    @implements(MyInterface)
    class NonConforming(object):
        pass