Guest User

ex47_tests.py

a guest
Mar 21st, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. from nose.tools import *
  2. from ex47.game import Room
  3.  
  4.  
  5. def test_room():
  6.     gold = Room("GoldRoom",
  7.                 """This room has gold in it you can grab. There's a
  8.               door to the north.""")
  9.     assert_equal(gold.name, "GoldRoom")
  10.     assert_equal(gold.paths, {})
  11.  
  12. def test_room_paths():
  13.     center = Room("Center", "Test room in the center.")
  14.     north = Room("North", "Test room in the north.")
  15.     south = Room("South", "Test room in the south.")
  16.  
  17.     center.add_paths({'north': north, 'south': south})
  18.     assert_equal(center.go('north'), north)
  19.     assert_equal(center.go('south'), south)
  20.    
  21. def test_map():
  22.     start = Room("Start", "You can go west and down a hole.")
  23.     west = Room("Trees", "There are trees here, you can go east.")
  24.     down = Room("Dungeon", "It's dark down here, you can go up.")
  25.  
  26.     start.add_paths({'west': west, 'down': down})
  27.     west.add_paths({'east': start})
  28.     down.add_paths({'up': start})
  29.  
  30.     assert_equal(start.go('west'), west)
  31.     assert_equal(start.go('west').go('east'), start)
  32.     assert_equal(start.go('down').go('up'), start)
Add Comment
Please, Sign In to add comment