Ejemplo n.º 1
0
 def test_to_python(self):
     f = ChoiceEnumField(enum_type=MyChoices)
     self.assertEqual(f.to_python(0), MyChoices.A)
     self.assertEqual(f.to_python('A'), MyChoices.A)
     self.assertEqual(f.to_python(1), MyChoices.B)
     with self.assertRaises(ValueError):
         f.to_python(None)
     with self.assertRaises(ValueError):
         f.to_python(3)
Ejemplo n.º 2
0
 def test_to_python(self):
     f = ChoiceEnumField(enum_type=MyChoices)
     self.assertEqual(f.to_python(0), MyChoices.A)
     self.assertEqual(f.to_python('A'), MyChoices.A)
     self.assertEqual(f.to_python(1), MyChoices.B)
     with self.assertRaises(ValueError):
         f.to_python(None)
     with self.assertRaises(ValueError):
         f.to_python(3)
Ejemplo n.º 3
0
def test_to_python():
    f = ChoiceEnumField(enum_type=MyChoices)
    assert f.to_python(0) == MyChoices.A
    assert f.to_python('A') == MyChoices.A
    assert f.to_python(1) == MyChoices.B
    with pytest.raises(ValueError):
        f.to_python(None)
    with pytest.raises(ValueError):
        f.to_python(3)
Ejemplo n.º 4
0
def test_to_python():
    f = ChoiceEnumField(enum_type=MyChoices)
    assert f.to_python(0) == MyChoices.A
    assert f.to_python('A') == MyChoices.A
    assert f.to_python(1) == MyChoices.B
    with pytest.raises(ValueError):
        f.to_python(None)
    with pytest.raises(ValueError):
        f.to_python(3)