コード例 #1
0
ファイル: test_fields.py プロジェクト: khchine5/django-shop
 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)
コード例 #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)
コード例 #3
0
ファイル: test_enum.py プロジェクト: yuang1516/django-shop
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)
コード例 #4
0
ファイル: test_enum.py プロジェクト: awesto/django-shop
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)