def test_ctx_update(mocked_context: _Context, ctx_store: dict): update_kwargs = {"c": 5, "d": 6} ctx_store.update(**update_kwargs) mocked_context.update(**update_kwargs) assert ctx_store == mocked_context assert mocked_context["c"] == 5 assert mocked_context["d"] == 6
def test_copy(mocked_context: _Context, ctx_store: dict): initial_data = mocked_context.data copied_data = mocked_context.copy() assert initial_data == copied_data copied_data["a"] = 123 assert initial_data != copied_data assert id(initial_data) == id(mocked_context.data) assert id(mocked_context.copy()) != id(mocked_context.copy())
def test_ctx_iter(mocked_context: _Context, ctx_store: dict): iterator = mocked_context.__iter__() assert next(iterator) == "a" assert next(iterator) == "b" assert next(iterator) == "c" with pytest.raises(StopIteration): next(iterator)
def test_ctx_repr(mocked_context: _Context, ctx_store: dict): assert str(ctx_store) == mocked_context.__repr__()