Beispiel #1
0
 def test_parse_will_set_default(self, parser: parseopt.Parser) -> None:
     parser.addoption("--hello", dest="hello", default="x", action="store")
     option = parser.parse([])
     assert option.hello == "x"
     del option.hello
     parser.parse_setoption([], option)
     assert option.hello == "x"
Beispiel #2
0
    def test_parse_setoption(self, parser: parseopt.Parser) -> None:
        parser.addoption("--hello", dest="hello", action="store")
        parser.addoption("--world", dest="world", default=42)

        option = argparse.Namespace()
        args = parser.parse_setoption(["--hello", "world"], option)
        assert option.hello == "world"
        assert option.world == 42
        assert not args