From ef269da39da24ecbaeb80d0d8f2d1ddb19479295 Mon Sep 17 00:00:00 2001 From: Fabian Zills <46721498+PythonFZ@users.noreply.github.com> Date: Fri, 8 Nov 2024 08:16:46 +0100 Subject: [PATCH] Dct-pop-test (#70) * fix `list.pop` by using Pipelines * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix test * update test to reflect only positiv integers * test `dict.pop` * test with default value --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- tests/test_dict.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_dict.py b/tests/test_dict.py index 590657a..aca7894 100644 --- a/tests/test_dict.py +++ b/tests/test_dict.py @@ -346,3 +346,20 @@ def test_dct_copy(client, request): with pytest.raises(ValueError): dct.copy(key="list:test:copy") + + +@pytest.mark.parametrize("client", ["znsclient", "znsclient_w_redis", "redisclient"]) +def test_dct_pop(client, request): + c = request.getfixturevalue(client) + dct = znsocket.Dict(r=c, key="list:test") + assert isinstance(dct, ZnSocketObject) + + dct.update({"a": "1", "b": "2"}) + + assert dct.pop("a") == "1" + assert dct == {"b": "2"} + + with pytest.raises(KeyError): + dct.pop("a") + + assert dct.pop("a", "default") == "default"