-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_circle.py
45 lines (29 loc) · 992 Bytes
/
test_circle.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
import pytest
import math
from .. import Circle
# Polytest Suite: circle
RADIUS = 7
circle = Circle(RADIUS)
# Polytest Group: circle
@pytest.mark.group_circle
def test_non_numeric():
"""Using a non-numeric radius should throw an error"""
with pytest.raises(ValueError):
Circle("Some radius")
@pytest.mark.group_circle
def test_diameter():
"""A circle should be able to accurately calculate its diameter"""
assert circle.diameter() == 14
@pytest.mark.group_circle
def test_radius():
"""A circle should be able to accurately calculate its radius"""
assert circle.radius == 7
# Polytest Group: shape
@pytest.mark.group_shape
def test_perimeter():
"""A shape should be able to accurately calculate its perimeter (or circumference)"""
assert circle.perimeter() == math.pi * RADIUS * 2
@pytest.mark.group_shape
def test_area():
"""A shape should be able to accurately calculate its area"""
assert circle.area() == math.pi * RADIUS**2