def labels(self): """ The full set of labels associated with with this *node*. This set is immutable and cannot be used to add or remove labels. Use methods such as :meth:`.add_label` and :meth:`.remove_label` for that instead. """ self.__ensure_labels() return LabelSetView(self._labels)
def labels(self): """ Set of all node labels. """ self.__ensure_labels() return LabelSetView(self._labels)
def test_iterable(self): view = LabelSetView(["A", "B", "C"]) self.assertSetEqual(set(view), {"A", "B", "C"})
def test_non_containment(self): view = LabelSetView(["A", "B", "C"]) self.assertNotIn("D", view)
def test_can_reselect_same(self): view = LabelSetView(["A", "B", "C"]).B.B.C self.assertEqual(repr(view), ":B:C")
def test_length(self): view = LabelSetView(["A", "B", "C"]) self.assertEqual(len(view), 3)
def test_can_chain_select(self): view = LabelSetView(["A", "B", "C"]).B.C self.assertEqual(repr(view), ":B:C")
def test_can_select_non_existing_in_view(self): view = LabelSetView(["A", "B"]).C self.assertEqual(repr(view), "")
def test_can_create_double_label_view(self): view = LabelSetView(["A", "B"]) self.assertEqual(repr(view), ":A:B")
def test_can_create_single_label_view(self): view = LabelSetView(["A"]) self.assertEqual(repr(view), ":A")
def test_can_create_empty_view(self): view = LabelSetView([]) self.assertEqual(repr(view), "")