style: black formatting on additional file

This commit is contained in:
Chris Davoren 2023-11-15 12:39:04 +10:00
parent a7e0b692c0
commit 38f23b340c
1 changed files with 27 additions and 18 deletions

View File

@ -3,8 +3,8 @@
import unittest
import toyrobot
class ToyRobotTests(unittest.TestCase):
class ToyRobotTests(unittest.TestCase):
def test_creation(self):
robot = toyrobot.Robot()
self.assertFalse(robot.is_initialized())
@ -17,25 +17,27 @@ class ToyRobotTests(unittest.TestCase):
def test_invalid_max_x(self):
exception_thrown = False
try:
robot = toyrobot.Robot(-1, 5)
except ValueError as ve:
toyrobot.Robot(-1, 5)
except ValueError:
exception_thrown = True
self.assertTrue(exception_thrown)
def test_invalid_max_y(self):
exception_thrown = False
try:
robot = toyrobot.Robot(5, -1)
except ValueError as ve:
toyrobot.Robot(5, -1)
except ValueError:
exception_thrown = True
self.assertTrue(exception_thrown)
def test_valid_place(self):
robot = toyrobot.Robot()
robot.place(1, 1, "NORTH")
self.assertTrue(robot.is_initialized() and \
robot.get_position() == (1, 1) and \
robot.get_direction() == "NORTH")
self.assertTrue(
robot.is_initialized()
and robot.get_position() == (1, 1)
and robot.get_direction() == "NORTH"
)
def test_invalid_place_position_x(self):
robot = toyrobot.Robot()
@ -66,17 +68,21 @@ class ToyRobotTests(unittest.TestCase):
robot = toyrobot.Robot()
robot.place(5, 5, "NORTH")
robot.place(2, 2)
self.assertTrue(robot.is_initialized() and \
robot.get_position() == (2, 2) and \
robot.get_direction() == "NORTH")
self.assertTrue(
robot.is_initialized()
and robot.get_position() == (2, 2)
and robot.get_direction() == "NORTH"
)
def test_double_place_2(self):
robot = toyrobot.Robot()
robot.place(5, 5, "NORTH")
robot.place(2, 2, "SOUTH")
self.assertTrue(robot.is_initialized() and \
robot.get_position() == (2, 2) and \
robot.get_direction() == "SOUTH")
self.assertTrue(
robot.is_initialized()
and robot.get_position() == (2, 2)
and robot.get_direction() == "SOUTH"
)
def test_valid_movement_x(self):
robot = toyrobot.Robot()
@ -150,9 +156,11 @@ class ToyRobotTests(unittest.TestCase):
robot.move()
robot.place(3, 1)
robot.move()
self.assertTrue(robot.is_initialized() and \
robot.get_position() == (3, 2) and \
robot.get_direction() == "NORTH")
self.assertTrue(
robot.is_initialized()
and robot.get_position() == (3, 2)
and robot.get_direction() == "NORTH"
)
def test_example_d_commands(self):
robot = toyrobot.Robot()
@ -164,5 +172,6 @@ class ToyRobotTests(unittest.TestCase):
robot.interpret_command("MOVE")
self.assertTrue(str(robot) == "3,2,NORTH")
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()