Exemplo n.º 1
0
 def test_parse_array_str(self) -> None:
     schema = {"type": "array", "items": {"type": "string"}}
     p = parse_schema_as_cmd(key="test_a",
                             schema=schema,
                             parser=self.parser)
     args = p.parse_args(["--test-a=1.1", "--test-a=2.2", "--test-a=3.3"])
     self.assertDictEqual(vars(args), {"test_a": ["1.1", "2.2", "3.3"]})
Exemplo n.º 2
0
 def test_parse_int(self) -> None:
     schema = {"type": "integer"}
     p = parse_schema_as_cmd(key="test_a",
                             schema=schema,
                             parser=self.parser)
     args = p.parse_args(["--test-a", "10"])
     self.assertDictEqual(vars(args), {"test_a": 10})
Exemplo n.º 3
0
 def test_parse_array_float(self) -> None:
     schema = {"type": "array", "items": {"type": "number"}}
     p = parse_schema_as_cmd(key="test_a",
                             schema=schema,
                             parser=self.parser)
     args = p.parse_args(["--test-a=1.1", "--test-a=2.2", "--test-a=3.3"])
     self.assertDictEqual(vars(args), {"test_a": [1.1, 2.2, 3.3]})
Exemplo n.º 4
0
 def test_parse_array_int(self) -> None:
     schema = {"type": "array", "items": {"type": "integer"}}
     p = parse_schema_as_cmd(key="test_a",
                             schema=schema,
                             parser=self.parser)
     args = p.parse_args(["--test-a=1", "--test-a=2", "--test-a=3"])
     self.assertDictEqual(vars(args), {"test_a": [1, 2, 3]})
Exemplo n.º 5
0
 def test_parse_bool_false(self) -> None:
     schema = {"type": "boolean"}
     p = parse_schema_as_cmd(key="test_a",
                             schema=schema,
                             parser=self.parser)
     args = p.parse_args([])
     self.assertDictEqual(vars(args), {"test_a": False})
Exemplo n.º 6
0
 def test_parse_string(self) -> None:
     schema = {"type": "string"}
     p = parse_schema_as_cmd(key="test_a",
                             schema=schema,
                             parser=self.parser)
     args = p.parse_args(["--test-a", "10a"])
     self.assertDictEqual(vars(args), {"test_a": "10a"})
Exemplo n.º 7
0
 def test_parse_noflag(self) -> None:
     schema = {"type": "string"}
     p = parse_schema_as_cmd(key="test_a",
                             schema=schema,
                             parser=self.parser,
                             noflag=True)
     args = p.parse_args(["noflag"])
     self.assertDictEqual(vars(args), {"test_a": "noflag"})