def test_views(bi, data): """Optimized view APIs should be equivalent to using the corresponding MappingViews from :mod:`collections.abc`.""" for check, oracle in (bi.keys(), KeysView(bi)), (bi.values(), ValuesView(bi)), (bi.items(), ItemsView(bi)): # 0-arity methods: __len__, __iter__ assert check.__len__() == oracle.__len__() assert list(check.__iter__()) == list(oracle.__iter__()) # 1-arity methods: __contains__ arg = data.draw( st.PAIRS if isinstance(oracle, ItemsView) else st.ATOMS) assert check.__contains__(arg) == oracle.__contains__(arg) # Methods of set-like views if isinstance(oracle, ValuesView): continue arg = data.draw(st.KEYSVIEW_SET_OP_ARGS if isinstance( oracle, KeysView) else st.ITEMSVIEW_SET_OP_ARGS) for so in _SET_OPS: try: expect = so(oracle, arg) except TypeError: with pytest.raises(TypeError): so(check, arg) else: check_ = so(check, arg) assert check_ == expect, (check, so, arg) try: expect = so(arg, oracle) except TypeError: with pytest.raises(TypeError): so(arg, check) else: check_ = so(arg, check) assert check_ == expect, (check, so, arg)
def values(self, *args: Any, max_len: Optional[int] = None) -> Iterator: # type: ignore # this is what the super type does and there is a test in dict_test.py # test_values which checks for this so we could disable the test or # keep this workaround if len(args) > 0: traceback_and_raise( TypeError( "values() takes 1 positional argument but 2 were given")) return Iterator(ValuesView(self), max_len=max_len)
def values(self): """Set-like object providing a view of index values. >>> index = Index() >>> index.update({'a': 1, 'b': 2, 'c': 3}) >>> values_view = index.values() >>> 2 in values_view True :return: values view """ return ValuesView(self)
def viewvalues(self): """Set-like object providing a view of index values. >>> index = Index('/tmp/diskcache/index') >>> index.clear() >>> index.update({'a': 1, 'b': 2, 'c': 3}) >>> values_view = index.viewvalues() >>> 2 in values_view True :return: values view """ return ValuesView(self)
def values(self): return ValuesView(self)
def viewvalues(self): "OMD.viewvalues() -> an object providing a view on OMD's values" return ValuesView(self)
def values(self): "D.values() -> an object providing a view on D's values" return ValuesView(self)
async def test_values(self): self.maxDiff = None conn = AMQPConnection(hostname="localhost", username="******", password="******") self.assertEqual(str(ValuesView(conn)), str(conn.values()))
assert theEmptySequence is EmptySequence() assert theEmptyThree is EmptyThree() if 1: #tmp assert not issubclass(EmptyMapping, Mapping) #MappingView.register(EmptyMapping) KeysView.register(EmptySet) ItemsView.register(EmptySet) ValuesView.register(EmptyCollection) assert issubclass(EmptySet, KeysView) assert issubclass(EmptySet, ItemsView) assert issubclass(EmptySet, Set) assert issubclass(EmptySet, MappingView) assert issubclass(EmptyCollection, ValuesView) assert issubclass(EmptyCollection, Collection) assert issubclass(EmptyCollection, MappingView) Mapping.register(EmptyMapping) Set.register(EmptySet) Sequence.register(EmptySequence) assert issubclass(EmptyMapping, Mapping) assert issubclass(EmptySet, Set)
def values(self, order=None): """Return a ValuesView in the given order, or the instance's ``order``, or the class' ``default_order``""" return ValuesView(self._to_ordered_dict(order or self.order))
def _abc_valuesview_register(view_cls): ValuesView.register(view_cls)
def values(self, fallback=True): # pylint: disable=arguments-differ return ValuesView(self if fallback else self._without_fallback())
def values(self): from collections.abc import ValuesView return ValuesView(self)