예제 #1
0
    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)
예제 #2
0
 def labels(self):
     """ Set of all node labels.
     """
     self.__ensure_labels()
     return LabelSetView(self._labels)
예제 #3
0
 def test_iterable(self):
     view = LabelSetView(["A", "B", "C"])
     self.assertSetEqual(set(view), {"A", "B", "C"})
예제 #4
0
 def test_non_containment(self):
     view = LabelSetView(["A", "B", "C"])
     self.assertNotIn("D", view)
예제 #5
0
 def test_can_reselect_same(self):
     view = LabelSetView(["A", "B", "C"]).B.B.C
     self.assertEqual(repr(view), ":B:C")
예제 #6
0
 def test_length(self):
     view = LabelSetView(["A", "B", "C"])
     self.assertEqual(len(view), 3)
예제 #7
0
 def test_can_chain_select(self):
     view = LabelSetView(["A", "B", "C"]).B.C
     self.assertEqual(repr(view), ":B:C")
예제 #8
0
 def test_can_select_non_existing_in_view(self):
     view = LabelSetView(["A", "B"]).C
     self.assertEqual(repr(view), "")
예제 #9
0
 def test_can_create_double_label_view(self):
     view = LabelSetView(["A", "B"])
     self.assertEqual(repr(view), ":A:B")
예제 #10
0
 def test_can_create_single_label_view(self):
     view = LabelSetView(["A"])
     self.assertEqual(repr(view), ":A")
예제 #11
0
 def test_can_create_empty_view(self):
     view = LabelSetView([])
     self.assertEqual(repr(view), "")