def test_modified_copy_builder(self):
        start: ImmutableSetMultiDict[str, int] = (
            ImmutableSetMultiDict.builder()
            .put("foo", 5)
            .put("bar", 6)
            .put("foo", 4)
            .build()
        )
        updated = (
            start.modified_copy_builder()
            .put("bar", 1)
            .put("foo", 7)
            .put("meep", -1)
            .build()
        )

        ref: ImmutableSetMultiDict[str, int] = (
            ImmutableSetMultiDict.builder()
            .put("foo", 5)
            .put("bar", 6)
            .put("foo", 4)
            .put("foo", 7)
            .put("bar", 1)
            .put("meep", -1)
            .build()
        )
        self.assertEqual(ref, updated)
 def test_inversion(self):
     x = ImmutableSetMultiDict.of({1: [2, 2, 3, 6], 4: [5, 6]})
     # when you start from a set multidict, your inverses as a list
     # and set multidict both contain the same items, since there
     # are no duplicate mappings in the source
     reference_set_based = ImmutableSetMultiDict.of(
         {2: [1], 3: [1], 5: [4], 6: [1, 4]}
     )
     reference_list_based = ImmutableListMultiDict.of(
         {2: [1], 3: [1], 5: [4], 6: [1, 4]}
     )
     self.assertEqual(reference_set_based, x.invert_to_set_multidict())
     self.assertEqual(reference_list_based, x.invert_to_list_multidict())
    def test_unmodified_copy_builder(self):
        ref: ImmutableSetMultiDict[str, int] = (
            ImmutableSetMultiDict.builder()
            .put("foo", 5)
            .put("bar", 6)
            .put("foo", 4)
            .build()
        )

        self.assertEqual(ref, ref.modified_copy_builder().build())
 def test_inversion(self):
     x = ImmutableListMultiDict.of({1: [2, 2, 3, 6], 4: [5, 6]})
     reference_set_based = ImmutableSetMultiDict.of(
         {2: [1], 3: [1], 5: [4], 6: [1, 4]}
     )
     # 2->1 appears twice because 1->2 appears twice in the source
     reference_list_based = ImmutableListMultiDict.of(
         {2: [1, 1], 3: [1], 5: [4], 6: [1, 4]}
     )
     self.assertEqual(reference_set_based, x.invert_to_set_multidict())
     self.assertEqual(reference_list_based, x.invert_to_list_multidict())
 def test_len(self):
     x = ImmutableSetMultiDict.of({1: [2, 2, 3], 4: [5, 6]})
     # note 4, not 5, because two of them are collapsed
     self.assertEqual(4, len(x))
     # len's implementation often does caching, so test it works twice
     self.assertEqual(4, len(x))
 def test_of(self):
     x = ImmutableSetMultiDict.of({1: [2, 2, 3], 4: [5, 6]})
     self.assertEqual(ImmutableSet.of([2, 3]), x[1])
     y = immutablesetmultidict([(1, 2), (1, 2), (1, 3), (4, 5), (4, 6)])
     self.assertEqual(immutableset([2, 3]), y[1])
 def test_set_str(self):
     self.assertEqual(
         "{1: {2, 3}, 4: {5, 6}}",
         str(ImmutableSetMultiDict.of({1: [2, 3], 4: [5, 6]})),
     )
 def test_empty_singleton(self):
     empty1 = immutablesetmultidict()
     empty2 = immutablesetmultidict()
     self.assertIs(empty1, empty2)
     empty4 = ImmutableSetMultiDict.of(dict())
     self.assertIs(empty1, empty4)
 def test_empty(self):
     empty = immutablesetmultidict()
     self.assertEqual(0, len(empty))
     empty2 = ImmutableSetMultiDict.of(dict())
     self.assertEqual(0, len(empty2))
     self.assertEqual(empty, empty2)