rover: define default values for Rover fields

This commit is contained in:
Bruno BELANYI 2019-11-15 20:35:19 +01:00
parent b90f92e557
commit b6d74b24eb
2 changed files with 7 additions and 2 deletions

View file

@ -9,5 +9,5 @@ class Vector:
@dataclass
class Rover:
pos: Vector
planet_size: Vector
pos: Vector = (0, 0)
planet_size: Vector = (100, 100)

View file

@ -4,3 +4,8 @@ from rover import Rover
def test_rover_constructor():
rov = Rover(pos=(0, 0), planet_size=(100, 100))
assert rov.pos == (0, 0) and rov.planet_size == (100, 100)
def test_rover_default_values():
rov = Rover()
assert rov.pos == (0, 0) and rov.planet_size == (100, 100)