def test_inspect_key_filter(tmp_path):
    """Inspect command with key filter argument"""
    instance_name = get_current_test_name()

    setting_file = tmp_path / "a.toml"
    environ = {"DYNACONF_FOO": "from_environ_key_filter"}
    cmd = ["-i", f"{instance_name}.settings", "inspect", "-k", "bar"]

    create_file(
        tmp_path / f"{instance_name}.py",
        f"""\
        settings = __import__('dynaconf').Dynaconf(
            settings_file="{setting_file.as_posix()}"
        )
        """,
    )

    create_file(
        setting_file,
        """\
        foo='from_file_key_filter'
        bar='file_only'
        """,
    )

    result = run(cmd, env=environ)
    expected_header = """\
        {
          "header": {
            "env_filter": "None",
            "key_filter": "bar",
            "new_first": "True",
            "history_limit": "None",
            "include_internal": "False"
          },
          "current": "file_only",
        """
    assert result
    assert result.startswith(dedent(expected_header))
Inspect command with key filter argument
tests/test_cli.py