forked from sbu-python-class/python-science
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_class.py
More file actions
31 lines (23 loc) · 805 Bytes
/
test_class.py
File metadata and controls
31 lines (23 loc) · 805 Bytes
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
# a test class is useful to hold data that we might want setup
# for every test.
import numpy as np
from numpy.testing import assert_array_equal
class TestClassExample(object):
@classmethod
def setup_class(cls):
""" this is run once for each class, before any tests """
pass
@classmethod
def teardown_class(cls):
""" this is run once for each class, after all tests """
pass
def setup_method(self):
""" this is run before each of the test methods """
self.a = np.arange(24).reshape(6, 4)
def teardown_method(self):
""" this is run after each of the test methods """
pass
def test_max(self):
assert self.a.max() == 23
def test_flat(self):
assert_array_equal(self.a.flat, np.arange(24))