def test_desc_contains_contents_if_desc_reveal(self): subject = Surface(self.game, self._get_unique_noun()) subject.desc_reveal = True content = Thing(self.game, self._get_unique_noun()) subject.addThing(content) self.start_room.addThing(subject) self.game.turnMain(f"l") msg = self.app.print_stack.pop() self.assertIn(content.verbose_name, msg)
def test_xdesc_does_not_contain_contents_if_not_xdesc_reveal(self): subject = Surface(self.game, self._get_unique_noun()) subject.xdesc_reveal = False content = Thing(self.game, self._get_unique_noun()) subject.addThing(content) self.start_room.addThing(subject) self.game.turnMain(f"x {subject.verbose_name}") msg = self.app.print_stack.pop() self.assertNotIn(content.verbose_name, msg)
class TestSaveLoadNested(IFPTestCase): def setUp(self): super().setUp() FILENAME = f"_ifp_tests_saveload__{uuid.uuid4()}.sav" path = os.path.dirname(os.path.realpath(__file__)) self.path = os.path.join(path, FILENAME) self.item1 = Surface(self.game, "table") self.item2 = Container(self.game, "box") self.item3 = Container(self.game, "cup") self.item4 = Thing(self.game, "bean") self.item5 = Thing(self.game, "spider") self.start_room.addThing(self.item1) self.item1.addThing(self.item2) self.item2.addThing(self.item3) self.item3.addThing(self.item4) self.item2.addThing(self.item5) SaveGame(self.game, self.path) self.start_room.removeThing(self.item1) self.item1.removeThing(self.item2) self.item2.removeThing(self.item3) self.item3.removeThing(self.item4) self.item2.removeThing(self.item5) def test_load(self): l = LoadGame(self.game, self.path) self.assertTrue(l.is_valid(), "Save file invalid. Cannot proceed.") l.load() self.assertItemExactlyOnceIn(self.item1, self.start_room.contains, "Failed to load top level item.") self.assertItemExactlyOnceIn( self.item2, self.item1.contains, "Failed to load item nested with depth 1.") self.assertItemExactlyOnceIn( self.item3, self.item2.contains, "Failed to load item nested with depth 2.") self.assertItemExactlyOnceIn( self.item5, self.item2.contains, "Failed to load item nested with depth 2.") self.assertItemExactlyOnceIn( self.item4, self.item3.contains, "Failed to load item nested with depth 3.") def tearDown(self): super().tearDown() os.remove(self.path)