From 6e31096db12499cd1298dd126307657b379542f3 Mon Sep 17 00:00:00 2001 From: fr2d9y2 Date: Fri, 7 Apr 2017 10:31:29 -0700 Subject: [PATCH] Elaborate: add obstacle in path --- mars-rover/test/test_rover.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mars-rover/test/test_rover.py b/mars-rover/test/test_rover.py index 70574e1..bc26cec 100644 --- a/mars-rover/test/test_rover.py +++ b/mars-rover/test/test_rover.py @@ -182,21 +182,26 @@ class TestObstacle: def setup(self): global p p = planet.Planet(20, 20) + p.setObstacle(10, 12); def test_east_forward(self): - p.setObstacle(10, 12); r = p.createRover(9, 12, 'E') with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"): r.move(list("f")) def test_north_forward(self): - p.setObstacle(10, 12) r = p.createRover(10, 11, 'N') with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"): r.move(list("f")) def test_west_back(self): - p.setObstacle(10, 12); r = p.createRover(9, 12, 'W') with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"): r.move(list("b")) + + def test_path_stops_before(self): + r = p.createRover(12, 11, 'W') + with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"): + r.move(list("fflb")) + assert_equal(10, r.x) + assert_equal(11, r.y)