def test_tab_info_is_removed_when_tab_is_removed(self): self.tabs.set_info(self.tabs.get_id(TabID(999)), hey='you') self.tabs.set_info(self.tabs.get_id(TabID(1099)), out='there') self.tabs.remove(1) self.assertEqual(self.tabs._info, {TabID(999): {'hey': 'you'}}) self.tabs.remove(0) self.assertEqual(self.tabs._info, {})
def test_focus_id_property(self): for i, tabid in enumerate([self.tabs.get_id(0), self.tabs.get_id(1)]): self.tabs.focus_id = self.tabs.get_id(tabid) self.assertEqual(self.tabs.focus_id, self.tabs.get_id(tabid)) self.assertEqual(self.tabs.focus_position, i) with self.assertRaises(IndexError) as cm: self.tabs.focus_id = TabID(123) self.assertIn('ID', str(cm.exception)) self.assertIn('123', str(cm.exception))
def test_get_id_by_nonexisting_id(self): with self.assertRaises(IndexError) as cm: self.tabs.get_id(TabID(-42)) self.assertIn('ID', str(cm.exception)) self.assertIn('-42', str(cm.exception))
def make_large_id(existing_ids): if not existing_ids: return TabID(999) else: return TabID(max(existing_ids) + 100)
def test_get_set_info_by_nonexisting_id(self): with self.assertRaises(IndexError) as cm: self.tabs.get_info(TabID(1000000)) self.assertIn('ID', str(cm.exception)) self.assertIn('1000', str(cm.exception))