code: def test_keygen():
      # a partial with a 'fixed' x, and positionally 'unsettable' b
      p = partial(bar, 0, b=10)
      s = signature(p)
      assert s == (
          ("y", "z", "a", "!b"),
          {"a": 1, "!x": 0, "b": 10},
          "args",
          "",
      )
  
      ignored = (0, 1, 3, 5, "*", "b", "c")
      user_args = ("0", "1", "2", "3", "4", "5", "6")
      user_kwds = {"a": "10", "b": "20", "c": "30", "d": "40"}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ()
      assert key_kwds == {
          "a": "2",
          "c": NULL,
          "b": NULL,
          "d": "40",
          "y": NULL,
          "z": NULL,
      }
  
      ignored = (0, 1, 3, 5, "**", "b", "c")
      user_args = ("0", "1", "2", "3", "4", "5", "6")
      user_kwds = {"a": "10", "b": "20", "c": "30", "d": "40"}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ("4", NULL, "6")
      assert key_kwds == {"a": "2", "b": NULL, "y": NULL, "z": NULL}
  
      ignored = ("*", "**")
      user_args = ("0", "1", "2", "3", "4", "5", "6")
      user_kwds = {"a": "10", "b": "20", "c": "30", "d": "40"}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ()
      assert key_kwds == {"a": "2", "b": "3", "y": "0", "z": "1"}
  
      ignored = (0, 2)
      user_args = ("0", "1", "2", "3", "4", "5", "6")
      user_kwds = {"a": "10", "b": "20", "c": "30", "d": "40"}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ("4", "5", "6")
      assert key_kwds == {
          "a": NULL,
          "c": "30",
          "b": "3",
          "d": "40",
          "y": NULL,
          "z": "1",
      }
  
      ignored = (0,)
      user_args = ("0", "1", "2", "3", "4", "5", "6")
      user_kwds = {"a": "10", "b": "20", "c": "30", "d": "40", "y": 50}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ("4", "5", "6")
      assert key_kwds == {
          "a": "2",
          "c": "30",
          "b": "3",
          "d": "40",
          "y": NULL,
          "z": "1",
      }
  
      ignored = ("a", "y", "c")
      user_args = ("0", "1", "2", "3", "4", "5", "6")
      user_kwds = {"a": "10", "b": "20", "c": "30", "d": "40", "y": 50}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ("4", "5", "6")
      assert key_kwds == {
          "a": NULL,
          "c": NULL,
          "b": "3",
          "d": "40",
          "y": NULL,
          "z": "1",
      }
  
      ignored = (1, 5, "a", "y", "c")
      user_args = ("0", "1")
      user_kwds = {}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ()
      assert key_kwds == {
          "a": NULL,
          "y": NULL,
          "b": 10,
          "z": NULL,
      }  # XXX: c?
  
      ignored = (1, 5, "a", "y", "c")
      user_args = ()
      user_kwds = {"c": "30", "d": "40", "y": 50}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ()
      assert key_kwds == {
          "a": NULL,
          "y": NULL,
          "c": NULL,
          "d": "40",
          "b": 10,
          "z": NULL,
      }
  
      ignored = (1, 5, "a", "c")
      user_args = ("0", "1")
      user_kwds = {}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ()
      assert key_kwds == {
          "a": NULL,
          "y": "0",
          "b": 10,
          "z": NULL,
      }  # XXX: c?
  
      ignored = ()
      user_args = ("0",)
      user_kwds = {"c": "30"}
      key_args, key_kwds = _keygen(p, ignored, *user_args, **user_kwds)
      assert key_args == ()
      assert key_kwds == {"a": 1, "y": "0", "b": 10, "c": "30"}
  
file_path: klepto/klepto/tests/test_ignore.py
imports: import sys
  from functools import partial
  from klepto.keymaps import hashmap
  from klepto import NULL
  from klepto import signature, keygen
  from klepto import _keygen, isvalid
  from klepto.tools import IS_PYPY
label_desc: Use image node_id 3 for calling a global function with example usage: test_keygen() without return types