Exemplo n.º 1
0
 def test_len(self, underlay, overlay):
     """
     ``__len__`` of the proxy does not count duplicates.
     """
     proxy = _MergingMappingProxy(
         overlay=overlay, underlay=underlay)
     self.assertThat(len(proxy), Equals(len(list(proxy))))
Exemplo n.º 2
0
 def test_iter(self, underlay, overlay):
     """
     ``__iter__`` of the proxy does not produce duplicate keys.
     """
     proxy = _MergingMappingProxy(overlay=overlay, underlay=underlay)
     keys = sorted(list(proxy))
     self.assertThat(keys, Equals(sorted(list(set(keys)))))
Exemplo n.º 3
0
 def test_iter(self, underlay, overlay):
     """
     ``__iter__`` of the proxy does not produce duplicate keys.
     """
     proxy = _MergingMappingProxy(
         overlay=overlay, underlay=underlay)
     keys = sorted(list(proxy))
     self.assertThat(keys, Equals(sorted(list(set(keys)))))
Exemplo n.º 4
0
 def test_get_underlay(self, underlay, overlay, key):
     """
     Getting an key that only exists in the underlay returns the value from
     the underlay.
     """
     underlay[key] = object()
     overlay.pop(key, None)
     proxy = _MergingMappingProxy(overlay=overlay, underlay=underlay)
     self.assertThat(proxy[key], Is(underlay[key]))
Exemplo n.º 5
0
 def test_contains(self, underlay, overlay, key):
     """
     The mapping only contains a key if it can be gotten.
     """
     proxy = _MergingMappingProxy(
         overlay=overlay, underlay=underlay)
     self.assertThat(
         key in proxy,
         Equals(proxy.get(key) is not None))
Exemplo n.º 6
0
 def test_get_both(self, underlay, overlay, key):
     """
     Getting an key that exists in both the underlay and the overlay returns
     the value from the overlay.
     """
     underlay[key] = object()
     overlay[key] = object()
     proxy = _MergingMappingProxy(overlay=overlay, underlay=underlay)
     self.assertThat(proxy[key], Not(Is(underlay[key])))
     self.assertThat(proxy[key], Is(overlay[key]))
Exemplo n.º 7
0
 def test_get_underlay(self, underlay, overlay, key):
     """
     Getting an key that only exists in the underlay returns the value from
     the underlay.
     """
     underlay[key] = object()
     overlay.pop(key, None)
     proxy = _MergingMappingProxy(
         overlay=overlay, underlay=underlay)
     self.assertThat(proxy[key], Is(underlay[key]))
Exemplo n.º 8
0
 def test_get_both(self, underlay, overlay, key):
     """
     Getting an key that exists in both the underlay and the overlay returns
     the value from the overlay.
     """
     underlay[key] = object()
     overlay[key] = object()
     proxy = _MergingMappingProxy(
         overlay=overlay, underlay=underlay)
     self.assertThat(proxy[key], Not(Is(underlay[key])))
     self.assertThat(proxy[key], Is(overlay[key]))
Exemplo n.º 9
0
 def test_contains(self, underlay, overlay, key):
     """
     The mapping only contains a key if it can be gotten.
     """
     proxy = _MergingMappingProxy(overlay=overlay, underlay=underlay)
     self.assertThat(key in proxy, Equals(proxy.get(key) is not None))
Exemplo n.º 10
0
 def test_len(self, underlay, overlay):
     """
     ``__len__`` of the proxy does not count duplicates.
     """
     proxy = _MergingMappingProxy(overlay=overlay, underlay=underlay)
     self.assertThat(len(proxy), Equals(len(list(proxy))))