-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_task_1.py
49 lines (37 loc) · 996 Bytes
/
test_task_1.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
import numpy as np
import pytest
from task_1 import Thingy, func
class TestFunc:
def test_1(self):
ar = np.ones(10)
assert func(ar) == 0
def test_2(self):
ar = np.ones(10)
ar[0] = np.NaN
with pytest.raises(ValueError):
func(ar)
class TestThingy:
def test_1(self):
thingy = Thingy()
assert len(thingy) == 0
inputs = [1, 2, 3]
thingy(inputs)
assert len(thingy) == len(inputs)
thingy(inputs)
assert len(thingy) == len(inputs)
def test_2(self):
inputs = (1, 2, 3)
thingy = Thingy()
thingy(inputs)
for val in inputs:
assert thingy[val] == 1
thingy(inputs)
for val in inputs:
assert thingy[val] == 2
def test_3(self):
thing = Thingy()
assert isinstance(str(thing), str)
def test_4(self):
thingy = Thingy()
thingy('bob')
assert thingy['bob'] == 1