Exemplo n.º 1
0
 def test_init__invalid_choices(self):
     with pytest.raises(ValueError, match="choices contains a non"):
         argument_actions.EnumName(
             option_strings="--colour",
             dest="colour",
             type=Colour,
             choices=(Colour.Blue, "Pink"),
         )
Exemplo n.º 2
0
    def test_init__valid_choices(self):
        target = argument_actions.EnumName(
            option_strings="--colour",
            dest="colour",
            type=Colour,
            choices=(Colour.Blue, Colour.Red),
        )

        assert target.choices == ("Blue", "Red")
Exemplo n.º 3
0
 def test_init__type_not_an_enum(self):
     with pytest.raises(TypeError, match="type must be an Enum"):
         argument_actions.EnumName(option_strings="--colour",
                                   type=str,
                                   dest="colour")
Exemplo n.º 4
0
 def name_target(self):
     return argument_actions.EnumName(option_strings="--colour",
                                      dest="colour",
                                      type=Colour)
Exemplo n.º 5
0
 def test_init__type_not_provided(self):
     with pytest.raises(ValueError, match="type must be assigned an Enum"):
         argument_actions.EnumName(option_strings="--colour", dest="colour")