def test_ordering(self):
     self.assertEqual(
         ("a", "b", "c"),
         tuple(
             ImmutableSet.builder(order_key=lambda x: x).add_all(
                 ["b", "c", "a"]).build()),
     )
 def test_empty_singleton(self):
     empty1 = immutableset()
     empty2 = immutableset()
     self.assertIs(empty1, empty2)
     empty3 = ImmutableSet.builder().build()
     self.assertIs(empty1, empty3)
     empty4 = immutableset([])
     self.assertIs(empty1, empty4)
 def test_empty(self):
     empty = immutableset()
     self.assertEqual(0, len(empty))
     empty2 = immutableset([])
     self.assertEqual(0, len(empty2))
     self.assertEqual(empty, empty2)
     empty3 = ImmutableSet.builder().build()
     self.assertEqual(0, len(empty3))
     self.assertEqual(empty, empty3)
Beispiel #4
0
 def __init__(
     self,
     *,
     source: Optional["ImmutableMultiDict[KT2,VT2]"] = None,
     order_key: Callable[[VT2], Any] = None,
 ) -> None:
     self._dict: MutableMapping[
         KT2, ImmutableSet.Builder[VT2]] = defaultdict(
             lambda: ImmutableSet.builder(order_key=order_key))
     self._source = source
     self._dirty = False