def getExits(self): reply = "\n" numExits = sum([1 for exit in self.exits if exit is not None]) if numExits == 0: reply += "There are no %s in any direction." % self.getExitName() else: if numExits == 1: reply += "There is a %s to the " % self.getExitName() else: reply += "There are %ss to the " % self.getExitName() exitNames = [util.getDirectionName(exit) for exit, room in enumerate(self.exits) if room is not None] reply += util.enumerateExits(exitNames) reply += "." return reply
def test_getDirectionName(self): result = [util.getDirectionName(x) for x in xrange(11)] expected = ["north", "south", "east", "west", "northeast", "southeast", "southwest", "northwest", "center", "up", "down"] self.assertEqual(result, expected)