Ejemplo n.º 1
0
 def test_Enum(self) -> None:
     p = Enum("red", "green")
     with pytest.raises(ValueError) as e:
         p.validate("junk")
     assert matches(
         str(e.value),
         r"invalid value: 'junk'; allowed values are red or green")
Ejemplo n.º 2
0
 def test_Enum(self, detail):
     p = Enum("red", "green")
     with pytest.raises(ValueError) as e:
         p.validate("junk", detail)
     assert str(e).endswith("ValueError") == (not detail)
Ejemplo n.º 3
0
 def test_Enum(self):
     p = Enum("red", "green")
     with pytest.raises(ValueError) as e:
         p.validate("junk")
     assert not str(e).endswith("ValueError")
Ejemplo n.º 4
0
 def test_Enum(self, detail) -> None:
     p = Enum("red", "green")
     with pytest.raises(ValueError) as e:
         p.validate("junk", detail)
     assert (str(e.value) == "") == (not detail)
Ejemplo n.º 5
0
 def test_Enum(self, detail):
     p = Enum("red", "green")
     with pytest.raises(ValueError) as e:
         p.validate("junk", detail)
     assert str(e).endswith("ValueError") == (not detail)
Ejemplo n.º 6
0
 def test_Enum(self):
     p = Enum("red", "green")
     with pytest.raises(ValueError) as e:
         p.validate("junk")
     assert not str(e).endswith("ValueError")