~testing-cabal/ubuntu/oneiric/tribunal/daily-build-packaging

« back to all changes in this revision

Viewing changes to tribunal/test/test_testing.py

  • Committer: Jelmer Vernooij
  • Date: 2010-08-23 22:28:24 UTC
  • mfrom: (161.2.1 upstream)
  • Revision ID: jelmer@samba.org-20100823222824-wre9thghcd7pee55
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from zope.interface import implements, Interface
2
 
from tribunal.testing import TestCase
3
 
 
4
 
 
5
 
class IFoo(Interface):
6
 
    def foo():
7
 
        pass
8
 
 
9
 
 
10
 
class IBar(Interface):
11
 
    def bar():
12
 
        pass
13
 
 
14
 
 
15
 
class Foo(object):
16
 
    """Correctly implements IFoo."""
17
 
    implements(IFoo)
18
 
 
19
 
    def foo(self):
20
 
        pass
21
 
 
22
 
 
23
 
class Goo(object):
24
 
    """Claims to implement IFoo."""
25
 
    implements(IFoo)
26
 
 
27
 
 
28
 
class Hoo(object):
29
 
    """Implements IFoo but doesn't declare it."""
30
 
 
31
 
    def foo(self):
32
 
        pass
33
 
 
34
 
 
35
 
class Qux(object):
36
 
    """Doesn't implement anything."""
37
 
 
38
 
 
39
 
class TestAssertImplements(TestCase):
40
 
 
41
 
    def test_success(self):
42
 
        self.assertImplements(Foo(), IFoo)
43
 
 
44
 
    def test_declared_not_implemented(self):
45
 
        self.assertImplements(Goo(), IFoo)
46
 
 
47
 
    def test_implemented_not_declared(self):
48
 
        self.assertRaises(
49
 
            self.failureException, self.assertImplements, Hoo(), IFoo)
50
 
 
51
 
    def test_not_implemented(self):
52
 
        self.assertRaises(
53
 
            self.failureException, self.assertImplements, Qux(), IFoo)
54
 
 
55
 
    def test_implements_something_else(self):
56
 
        self.assertRaises(
57
 
            self.failureException, self.assertImplements, Foo(), IBar)