def test_room_paths(): center = Room("Center", "Test room in the center.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") center.add_paths({'north':north,'south':south}) assert_equal(center.go('north'), north) assert_equal(center.go('south'), south)
def test_room_paths(): center = Room("Center", "가운데의 테스트 방.") north = Room("North", "북쪽의 테스트 방.") south = Room("South", "남쪽의 테스트 방.") center.add_paths({'north': north, 'south': south}) assert_equal(center.go('north'), north) assert_equal(center.go('south'), south)
def test_room(): gold = Room("GoldRoom", """This room has gold in it you can grab. There's a door to the north.""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {}) descr = gold.look() assert_equal(descr.split(' ')[1], "room") assert_equal(descr.split(' ')[3], "gold")
def test_room_paths(): center = Room("Center", "Test room in the center.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") center.add_paths({"north": north, "south": south}) assert_equal(center.go("north"), north) assert_equal(center.go("south"), south)
def test_room_paths() : center = Room('Center', 'Test room in the center.') north = Room('North', 'Test room in the north.') south = Room('South', 'Test room in the south.') center.add_paths({'north' : north, 'south' : south}) assert_equal(center.go('north'), north) assert_equal(center.go('south'), south)
def test_room_paths(): center = Room('center', 'no centro') north = Room('north', 'no norte') south = Room('south', 'no sul') center.add_paths({'north': north, 'south': south}) assert_equal(center.go('north'), north) assert_equal(center.go('south'), south)
def test_room_paths(): center=Room("Center","test room un the center") north=Room("Center","test room un the North") south=Room("Center","test room un the center") center.add_paths({'north':north , 'south':south}) assert_equal(center.go('north'),north) assert_equal(center.go('south'),south)
def test_room_paths(): center = Room("Center", "Test room is in the Center") north = Room("North", "Test room is in the North") south = Room("South", "Test room is in the South") center.add_paths({"North" : north, "South" : south}) assert_equal(center.go("North"), north) assert_equal(center.go("South"), south)
def test_room_paths(): center = Room("center", "test center room") north = Room("north", "test north room") south = Room("south", "test south room") center.add_paths({'north': north, 'south': south}) assert_equal(center.go('north'), north) assert_equal(center.go('south'), south)
def test_removal(): room1 = Room("Room1", "Test Room1.") room2 = Room("Room2", "Test Room2.") room3 = Room("Room3", "Test Room3.") room1.add_paths({'Room2': room2}) room1.add_paths({'Room3': room3}) assert_equal(room1.room_size(),2) room1.remove_path("Room2") assert_equal(room1.room_size(),1) room1.remove_path("Room3") assert_equal(room1.room_size(),0)
def test_room_paths(): # Creates 3 instances of Room, no paths center = Room("Center", "Test room in the center.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") # Add paths to the center room (K/V in paths) center.add_paths({'north':north,'south':south}) # Tests these links assert_equal(center.go('north'),north) assert_equal(center.go('south'),south)
def test_room_paths(): ## create center Room() object, named "Center" center = Room("Center", "Test room in the center.") ## create north Room() object, named "North" north = Room("North", "Test room in the north.") ## create north Room() object, name "South" south = Room("South", "Test room in the south.") ## add a dictionary to center object center.add_paths({'north': north, 'south': south}) ## test to see if north equals north in the center.path dictionary. assert_equal(center.go('north'), north) ## test to see if south equals south in the center.path dictionary. assert_equal(center.go('south'), south)
def test_map(): start = Room("Start","You can go west and down a hole.") west = Room("Trees","There are trees here,you can go east.") start.add_paths({'west':west,'down':down}) west.add_paths({'west':start}) down.add_paths({'up':start}) assert_equal(start.go('west'),west) assert_equal(start.go('west').go('east'),start) assert_equal(start.go('down').go('up'),start)
def test_room_paths(): # 将Room类实例化 center = Room("Center", "Test room in the ceter.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") # 将参数中的字典更新到paths字典中 center.add_paths({'north': north, 'south': south}) # 测试center实例中的go方法,查找north键并返回字典值,测试字典值是不是north实例对象返回值,否则报异常 assert_equal(center.go('north'), north) # 测试center实例中的go方法,查找south键并返回字典值,测试字典值是不是south实例对象返回值,否则报异常 assert_equal(center.go('south'), south)
def test_room_grab_things(): gold = Room("GoldRoom", """This room has gold in it you can grab.""") coins = Room("Coins", "Money") dark_room = Room('DarkRoom', "This room has nothing except darknes.") emptyness = Room("Emptyness", "Dark room is emty") gold.grab_things({'coins': coins}) dark_room.grab_things({'emptyness': emptyness}) assert_equals(gold.check_bag('coins'), coins) assert_equals(dark_room.check_bag('emptyness'), emptyness)
def test_add_enemy(): a=Room('test','Nothing to see here') b=Room('NO!','Just No') a.add_paths({"no": b}) a.add_enemy("there is a testenemy here") c=a.description assert_equal(c,"""Nothing to see here\nthere is a testenemy here""") assert_equal(a.go(b),"can't go there")
def test_rooms(): intro = Room("the Intro Room", """You are in the intro-room. There is an exit South.""") apartment = Room("your Apartment", """You are in your apartment. Its a very fancy and luxurious pad that sits just below the Earth's ozone layer. There is an exit North, East and West""") intro.add_paths({'south': apartment}) apartment.add_paths({'north': intro}) print_commands()
def test_room(): text = "This room has a pile of gold. There's a door to the north." gold = Room("GoldRoom", text) assert gold.name == "GoldRoom" assert gold.description == text assert gold.paths == {}
def test_map(): # 将Room实例化 start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are tress here here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") # 将参数中的字典更新到paths字典中 start.add_paths({'west': west, 'down': down}) # 将参数中的字典更新到paths字典中 west.add_paths({'east': start}) # 将参数中的字典更新到paths字典中 down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("West", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark here, you can go up.") start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('east'), start) assert_equal(start.go('down'), start)
def test_map(): start=Room("Start",'you can go west and down a hole') west=Room("Trees","ther are trees here you can go") down=Room("Dungeon","It's dark down here you can go") start.add_paths({'west':west,'down':down}) west.add_paths({'east':start}) down.add_paths({'up':start}) assert_equal(start.go('west'),west) assert_equal(start.go('west'),west).go('east'),start) assert_equal(start.go('down').go('up'),start)
def test_map(): start = Room("Start", "") west = Room("Trees", "") down = Room("Dungeon", "") start.add_paths({"west": west, "down": down}) west.add_paths({"east": start}) down.add_paths({"north": start}) assert (start.go("west") == west) assert (start.go("west").go("east") == start) assert (start.go("down").go("north") == start)
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.")
def test_map(): start = Room("Start", "You can go west and doom a hole.") west = Room("Trees", "There are trees here, you can go east.") done = Room("Dungeon", "It's dark down there, you can go up.") start.add_paths(['west': west, 'down': down])
def test_room_paths(): center = Room("Center", "Test room in the center") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") center.add_paths(["north": north, "south": south])
def test_room(): gold = Room( "GoldRoom", """This room has gold in it you can grab. There's a door in the north.""") assert_equal(gold.name, 'GoldRoom') assert_equal(gold.paths, dict())
def test_map(): # Creates 3 instances of Room, no paths start = Room("Start", "You can go west and down a hole.") west = Room("Trees","There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") # Add paths to all rooms start.add_paths({"west": west, "down": down}) west.add_paths({"east": start}) down.add_paths({'up' : start}) # Tests these links, and their chaining assert_equal(start.go("west"), west) assert_equal(start.go("west").go('east'), start) assert_equal(start.go("down").go("up"), start)
def test_map(): # Instantiate room and attribute it to variables start = Room("Start", "You can go west and down a hole") west = Room("Trees", "There are trees here. You can go east") down = Room("Dungeon", "It's dark down here. You can go up") #Links rooms together. i.e. start leads to west room. west leads to start room #instantiates add_paths and attributes it to start. start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) # instantiates go with args west etc and asserts whether value for west key = west assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start) # run 'nosetests' in to run all tests # nosetests -s prints some output # note that you're instantiating classes, and running methods on those classes # all within a function. Doing things within things within things.
def test_items(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") start.add_items({'book': "a book"}) west.add_items({'axe': "an axe"}) down.add_items({'key': "a key"}) assert_equal(start.take('book'), "a book") assert_equal(west.take('axe'), "an axe") assert_equal(down.take('key'), "a key")
def test_room(): gold = Room( "GoldRoom", "This room has gold in it you can grab. There's a door \ to the north") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def test_room(): gold = Room("GoldRoom","""This room""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") # These are all instances of the Room class and each one with have a different dict start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_room(): gold = Room("Gold Room", """Go north and/or grab gold""") assert (gold.name == "Gold Room") assert (gold.paths == {})
def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") start.add_paths({"west": west, "down": down}) west.add_paths({"east": start}) down.add_paths({"up": start}) assert_equal(start.go("west"), west) assert_equal(start.go("west").go("east"), start) assert_equal(start.go("down").go("up"), start)
def test_map(): start = Room('start','you can go west and down') west = Room('west', 'there are trees, you can go east') down = Room('dungeon', 'it is dark, you can go up') start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start) assert start.go('west') == west
from nose.tools import * from ex47.game import Room def test_room(): gold = Room("GoldRoom", """This room has gold in it you can grab. There's a door to the north.""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {} ) def test_room.paths(): center = Room("Center", "Test room in the center.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.") center.add_paths({'north': north, 'south': south}) assert_equal(center.go('north'), north) assert_equal(center.go('south'), south) def test_map(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It’s dark down here, you can go up.") start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west)
def test_map(): start = Room("Start", 'You can start') west = Room("West", 'You can west') down = Room("Down", 'You can down') start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_map(): start = Room('Start', 'You can go west and down a hole.') west = Room('Trees', 'There are trees here, you can go east.') down = Room('Dungeon', 'It\'s dark down here, you can go up.') start.add_paths({'west':west, 'down':down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_room(self): gold = Room( "GoldRoom", """This room has gold in it you can grab. There's a door to the north.""") self.assert_equal(gold.name, "GoldRoom") self.assert_equal(gold.paths, {})
def test_map(): start = Room("Start", "You are in a hall you can go through a north door") north = Room("Kitchen", "You mum's kitchen nice! you can go West") west = Room("Dungeon", "It dark here almost like a dungeon you can go South" ) south = Room("GoldRoom", "Oh yeah found my neXt box let's play a game") start.add_paths({'north': north, 'south': start}) north.add_paths({'west': west, 'east': north}) west.add_paths({'south': south, 'east': west}) assert_equal(start.go('north'), north) assert_equal(start.go('south'), start) # do not understand this principle assert_equal(north.go('west'), west) assert_equal(north.go('east'), north) assert_equal(west.go('south'), south)
def test_map(): start = Room("Start", "You can go west a down a hole.") east = Room("Mountain", "You can climbing the mountain!") west = Room("Tree", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up") start.add_paths({'west':west, 'down':down}) west.add_paths({'east':start}) down.add_paths({'up':start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_room_paths(): center = Room("Center", "Test room in the center.") north = Room("North", "Test room in the north.") south = Room("South", "Test room in the south.")
def test_map(): ## create a start Room() object start = Room("Start", "You can go west and down a hole.") ## create a west Room() object west = Room("Trees", "There are trees here, you can go east.") ## create a down Room() object down = Room("Dungeon", "It's dark down here, you can go up.") ## add a dictionary to start with the values west and down. start.add_paths({'west': west, 'down': down}) ## add a dictionary to west with the value east west.add_paths({'east': start}) ## add a dictionary to down with the value up down.add_paths({'up': start}) ## test to see if you can go west from start assert_equal(start.go('west'), west) ## test to see if you can go west and then east from start assert_equal(start.go('west').go('east'), start) ## test to see if you can go down and up from start assert_equal(start.go('down').go('up'), start)
def test_room(): gold = Room('GoldRoom', """This toom has gold in it you can grab. There is a door to the north.""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def test_hallway(): k_0 = Room("k_0", "0th room") k_1 = Room("k_1", "1st room") k_2 = Room("k_2", "2nd room") k_3 = Room("k_3", "3rd room") k_4 = Room("k_4", "4th room") # fwd, bk k_0.add_paths({'fwd': k_1}) k_1.add_paths({'bk': k_0, 'fwd': k_2}) k_2.add_paths({'bk': k_1, 'fwd': k_3}) k_3.add_paths({'bk': k_2, 'fwd': k_4}) k_4.add_paths({'bk': k_3}) assert_equal(k_0.go('fwd').go('fwd').go('fwd').go('fwd'), k_4)
def test_room(): gold = Room( "GoldRoom", """ This room has gold in it you grab,There`s a door to the north """) assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def test_people(): start = Room("Start", "You can go west and down a hole.") west = Room("Trees", "There are trees here, you can go east.") down = Room("Dungeon", "It's dark down here, you can go up.") start.add_people({"no one": "You sound crazy talking to yourself"}) west.add_people({"fox": "Wahpah wahpah wah pah-pow!"}) down.add_people({"Sterling Archer": "DANGER ZONE"}) assert_equal(start.talk("no one"), "You sound crazy talking to yourself") assert_equal(west.talk("fox"), "Wahpah wahpah wah pah-pow!") assert_equal(down.talk("Sterling Archer"), "DANGER ZONE")
def test_map(): start = Room('Start', "You can go west and down a hole") west = Room('Trees', "There are tree here,you can go west") down = Room('Dungeon', 'It`s dark down here ,you can go up') start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_room(): gold = Room("GoldRoom", "This room has gold you can grab") assert_equal(gold.name, "GoldRoom")
def test_room(): gold = Room( "GoldRoom", """This room has gold in it you cam grab. The door to the north.""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def test_map(): start = Room ("Start" , "You can go west and a hole") west = Room ("Trees", "There are trees here , you can go east") down = Room ("Sungeon" , "IT 's a dark down here, you can go up") start.add_paths ({ 'west' : west, 'down' : down}) west.add_paths ({'east' : start}) down.add_paths ({'up' : start}) assert_equal (start.go ('west'), west) assert_equal (start.go ('west').go('east'),start) assert_equal (start.go ('down').go('up'),start)
def test_map(): start = Room("Start", "Вы можете идти на запад и провалиться в яму.") west = Room("Trees", "Здесь есть деревья и вы можете отправиться на восток.") down = Room("Dungeon", "Здесь темно и вы можете подняться вверх.") start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_room(): gold = Room( "GoldRoom", """В этой комнате полно золота, которое можно украсть. Здесь есть дверь с выходом на север.""") assert_equal(gold.name, "GoldRoom") assert_equal(gold.paths, {})
def test_room(): gold = Room("GoldRoom" """This room has gold in it you can grab, There's a door to the north.""") assert_equal(gold.name, 'GoldRoom') assert_equal(gold.paths. [])
def test_map(): start = Room('Start', "You can go west and down a hill.") west = Room("Trees", "There are trees herem, you can go east.") down = Room("Dungeon", "It's a dark down here, you can go up.") start.add_paths({'west': west, 'down': down}) west.add_paths({'east': start}) down.add_paths({'up': start}) assert_equal(start.go('west'), west) assert_equal(start.go('west').go('east'), start) assert_equal(start.go('down').go('up'), start)
def test_map(): start = Room("Start","You can go west and down a hole.") west =Room("Trees","There are trees here,you can go east") down =Room("Dungeon","It's dark down here,you can go up.") start.add_paths({'west'.west,'down':down})
def test_room(): gold = Room("GoldRoom", # Initiates Room, passing name and desc params. """This room has gold in it you can grab. There's a door to the north.""") assert_equal(gold.name, "GoldRoom") # tests that gold.name is called "GoldRoom" assert_equal(gold.paths, {}) # tests that gold.paths is an empty dict