-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNose2.py
40 lines (31 loc) · 1.11 KB
/
Nose2.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
from a import A
from nose.tools import assert_equal
from nose.tools import assert_not_equal
from nose.tools import assert_raises
from nose.tools import raises
class TestA(object):
@classmethod
def setup_class(klass):
"""This method is run once for each class before any tests are run"""
@classmethod
def teardown_class(klass):
"""This method is run once for each class _after_ all tests are run"""
def setUp(self):
"""This method is run once before _each_ test method is executed"""
def teardown(self):
"""This method is run once after _each_ test method is executed"""
def test_init(self):
a = A()
assert_equal(a.value, "Some Value")
assert_not_equal(a.value, "Incorrect Value")
def test_return_true(self):
a = A()
assert_equal(a.return_true(), True)
assert_not_equal(a.return_true(), False)
def test_raise_exc(self):
a = A()
assert_raises(KeyError, a.raise_exc, "A value")
@raises(KeyError)
def test_raise_exc_with_decorator(self):
a = A()
a.raise_exc("A message")