Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(10)  |  Call(8)  |  Derive(0)  |  Import(2)

src/d/j/dj.choices-0.9.2/src/dj/choices/tests.py   dj.choices(Download)
    def test_regularintegers(self):
        from dj._choicestestproject.app.models import Color, RegularIntegers
        from dj._choicestestproject.app.forms import RegularIntegersForm
        rint = RegularIntegers.create()
        self.assertEqual(rint.color, Color.green.id)
        rint_invalid = RegularIntegers.create(color=-1)
        self.assertEqual(rint_invalid.color, -1)
        empty_form = RegularIntegersForm()
        self.assertFalse(empty_form.is_valid()) # because it's not bound
        valid_form = RegularIntegersForm(data={'color': 1})
        valid_form = RegularIntegersForm(data={'color': 1})
        self.assertTrue(valid_form.is_valid())
        invalid_form = RegularIntegersForm(data={'color': -1})
        self.assertFalse(invalid_form.is_valid())
        self.assertTrue('color' in invalid_form.errors)
        self.assertTrue('Select a valid choice' in
                invalid_form.errors['color'][0])
        invalid_type_form = RegularIntegersForm(data={'color': 'aaa'})

src/d/j/dj.choices-HEAD/src/dj/choices/tests.py   dj.choices(Download)
    def test_regularintegers(self):
        from dj._choicestestproject.app.models import Color, RegularIntegers
        from dj._choicestestproject.app.forms import RegularIntegersForm
        rint = RegularIntegers.create()
        self.assertEqual(rint.color, Color.green.id)
        rint_invalid = RegularIntegers.create(color=-1)
        self.assertEqual(rint_invalid.color, -1)
        empty_form = RegularIntegersForm()
        self.assertFalse(empty_form.is_valid()) # because it's not bound
        valid_form = RegularIntegersForm(data={'color': 1})
        valid_form = RegularIntegersForm(data={'color': 1})
        self.assertTrue(valid_form.is_valid())
        invalid_form = RegularIntegersForm(data={'color': -1})
        self.assertFalse(invalid_form.is_valid())
        self.assertTrue('color' in invalid_form.errors)
        self.assertTrue('Select a valid choice' in
                invalid_form.errors['color'][0])
        invalid_type_form = RegularIntegersForm(data={'color': 'aaa'})