Shapes.py

Summary

Lines:

16 of 18 covered (88.9%)

Excluded lines:

2

Branches:

2 of 4 taken (50.0%), 2 lines partially

Coverage:

81.8%

Directory:

myPackage

Missed lines:

8, 25

Source

myPackage/Shapes.pycoveredpartialuncoveredexcludednot executable
1"""Shapes with an area."""
2from math import pi
3
4
5class Circle:
6	def __init__(self, radius: float) -> None:
7		if radius < 0:
8			raise ValueError("Negative radius.")
9		self.radius = radius
10
11	def Area(self) -> float:
12		return pi * self.radius ** 2
13
14
15class Rectangle:
16	def __init__(self, width: float, height: float) -> None:
17		self.width = width
18		self.height = height
19
20	def Area(self) -> float:
21		return self.width * self.height
22
23	def IsSquare(self) -> bool:
24		if self.width == self.height:
25			return True
26		return False
27
28	def __repr__(self) -> str:  # pragma: no cover
29		return f"Rectangle({self.width}, {self.height})"