-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot.py
More file actions
40 lines (32 loc) · 682 Bytes
/
Copy pathdot.py
File metadata and controls
40 lines (32 loc) · 682 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
32
33
34
35
36
37
38
39
40
import pytest
def dot(a,b):
res = 0
for i in range(len(a)):
res += a[i]*b[i]
return res
#@ = decoration symbol. transforms the inmediately next function.
@pytest.mark.parametrize("a,b,expected",[
([0,0],[0,0],0),
([1,0],[0,1],0),
([1,2],[2,-1],0),
])
def test_asser_equal(a,b,expected):
assert dot(a,b) == expected
def test_dot_zeros():
a = [0,0]
b = [0,0]
assert dot(a,b) == 0
def test_dot_perp():
a = [0,1]
b = [1,0]
assert dot(a,b) == 0
def test_a_lessthan_b():
a = [1,2]
b = [1,2,3]
with pytest.raises(AssertionError):
assert dot(a,b) == 3
def test_b_lessthan_a():
a = [1,2]
b = [1,2,3]
with pytest.raises(AssertionError):
assert dot(a,b) == 3