test_commands.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. """Test suite.
  2. Copyright 2010-2015 Brandon Rhodes. Licensed as free software under the
  3. Apache License, Version 2.0 as detailed in the accompanying README.txt.
  4. """
  5. from unittest import TestCase
  6. from adventure import load_advent_dat
  7. from adventure.game import Game
  8. class CommandTest(TestCase):
  9. def setUp(self):
  10. game = Game()
  11. load_advent_dat(game)
  12. self.words = set(w.synonyms[0].text for w in game.vocabulary.values())
  13. self.words.remove('suspend')
  14. def test_intransitive_commands_should_not_throw_exceptions(self):
  15. for word in self.words:
  16. game = Game()
  17. load_advent_dat(game)
  18. game.start()
  19. game.do_command(['no']) # WOULD YOU LIKE INSTRUCTIONS?
  20. game.do_command([word])
  21. def test_transitive_commands_should_not_throw_exceptions(self):
  22. for word in self.words:
  23. game = Game()
  24. load_advent_dat(game)
  25. game.start()
  26. game.do_command(['no']) # WOULD YOU LIKE INSTRUCTIONS?
  27. game.do_command(['enter']) # so we are next to lamp
  28. game.do_command([word, 'lamp'])