forked from teresadatta/cs107test
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_roots.py
More file actions
31 lines (24 loc) · 776 Bytes
/
test_roots.py
File metadata and controls
31 lines (24 loc) · 776 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
import pytest
import roots
def test_quadroots_result():
assert roots.quad_roots(1.0, 1.0, -12.0) == ((3+0j), (-4+0j))
def test_quadroots_types():
with pytest.raises(TypeError):
roots.quad_roots("", "green", "hi")
def test_quadroots_zerocoeff():
with pytest.raises(ValueError):
roots.quad_roots(a=0.0)
def test_linearoots_result():
assert roots.linear_roots(2.0, -3.0) == 1.5
def test_linearroots_types():
with pytest.raises(TypeError):
roots.linear_roots("ocean", 6.0)
def test_linearroots_zerocoeff():
with pytest.raises(ValueError):
roots.linear_roots(a=0.0)
test_quadroots_result()
test_quadroots_types()
test_quadroots_zerocoeff()
test_linearoots_result()
test_linearroots_types()
test_linearroots_zerocoeff()