-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_subject_test.py
65 lines (45 loc) · 1.32 KB
/
example_subject_test.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
"""A hacky demo of how you can use pyJazz."""
import mock
from jazz import *
from example_subject import Subject
class Adder(Describe):
def before_each(self):
self.subject = Subject()
@it
def ShouldCallback(self):
callback = mock.Mock()
self.subject.callback(callback)
expect(callback).toHaveBeenCalled()
expect(callback).toHaveBeenCalledWith(42, foo='bar')
@it
def ShouldAddTwoNumbers(self):
actual = self.subject.add(2, 3)
expect(actual).toEqual(5)
@it
def ShouldAtLeastAddSomething(self):
actual = self.subject.add(2, 3)
expect(actual).toBeGreaterThan(2)
class Sub(Describe):
def before_each(self):
self.subject = Subject()
@it
def ShouldBeASubTest(self):
actual = self.subject.add(2, 3)
expect(actual).toBeLessThan(6)
class SubSub(Describe):
def it_should_keep_nesting(self): pass
@it
def ShouldJustRun(self):
expect(self.subject.just_run).toRaise()
class AdderPep8(Describe):
def it_should_add_two_numbers(self):
subject = Subject()
expect(subject.add(2, 3)).toEqual(5)
def it_should_at_least_add_something(self):
subject = Subject()
expect(subject.add(2, 3)).toBeGreaterThan(2)
def it_should_just_run(self):
subject = Subject()
expect(subject.just_run).toRaise()
if __name__ == '__main__':
run()