예제 #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")
예제 #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)
예제 #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")
예제 #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)
예제 #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)
예제 #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")