Skip to content

Commit

Permalink
✅ DictParamType tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkarimi1383 committed Sep 17, 2024
1 parent f83e798 commit 2b480ad
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/test_others.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import subprocess
import sys
Expand All @@ -12,7 +13,7 @@
import typer.completion
from typer.core import _split_opt
from typer.main import solve_typer_info_defaults, solve_typer_info_help
from typer.models import ParameterInfo, TyperInfo
from typer.models import ParameterInfo, TyperInfo, DictParamType
from typer.testing import CliRunner

runner = CliRunner()
Expand Down Expand Up @@ -275,3 +276,19 @@ def test_split_opt():
prefix, opt = _split_opt("verbose")
assert prefix == ""
assert opt == "verbose"


def test_json_param_type_convert():
data = {"name": "Camila", "age": 15, "height_meters": 1.7, "female": True}
converted = DictParamType().convert(json.dumps(data), None, None)
assert data == converted


def test_json_param_type_convert_dict_input():
data = {"name": "Camila", "age": 15, "height_meters": 1.7, "female": True}
converted = DictParamType().convert(data, None, None)
assert data == converted


def test_dict_param_tyoe_name():
assert repr(DictParamType) == "DICT"

0 comments on commit 2b480ad

Please sign in to comment.