class LivingTestCase(unittest.TestCase): def setUp(self): pre_populate.populate() self.room = Living('crystal') def tearDown(self): del self.room reset.reset() def test_class(self): '''test object is instance of Living class''' self.assertTrue(isinstance(self.room, Living), 'is not an instance of Living') def test_subclass(self): '''test object is a subclass of Room''' self.assertTrue(issubclass(type(self.room), Room), 'is not a subclass of Room') def test_roomname_correct(self): '''test correct room name set''' self.assertEqual(self.room.room_name, 'crystal', 'incorrect room name was set') def test_space_count(self): '''test space limit is only 4''' self.assertLessEqual(self.room.space_count, 4, 'living space_count exceeds 4') def test_occupants(self): '''test occupants is initially empty''' self.assertEqual(len(self.room.occupants), 0, 'list of occupants not initially empty') def test_get_occupants(self): '''test occupant list''' self.assertIsNone(self.room.get_occupants()) def test_room_gender(self): '''test room gender initially None''' self.assertIsNone(self.room.room_gender, 'room gender not initially None')
def setUp(self): pre_populate.populate() self.room = Living('crystal')