class TestRoom(unittest.TestCase): def setUp(self): self.x = 5 self.y = 4 self.name = "Room to test your unit" self.description = "You see units standing, ready for test." self.exits = ['north', 'south'] self.room = Room(self.x, self.y, self.name, self.description, self.exits) def test_str(self): expected = f'{self.name}\n{self.description}' result = self.room.__str__() self.assertEqual(expected, result) def test_check_exit_positive(self): result = self.room._check_exit('north') self.assertTrue(result) def test_check_exit_negative(self): directions = ['west', 'North', 'vostok'] for direction in directions: with self.subTest(direction): result = self.room._check_exit(direction) self.assertFalse(result)
class TestRoom(unittest.TestCase): def setUp(self): self.x = 5 self.y = 4 self.name = "Room to test your unit" self.description = "You see units standing, ready for test" self.exits = ['This way', 'That way'] self.room = Room(self.x, self.y, self.name, self.description, self.exits) def test_str(self): result = self.room.__str__() self.assertIs(type(result), str)