Anyone have any experience with forms (ModelMultipleChoice fields and foreignkey'd choice fields) not validating properly in a unit test but just fine in the runserver?
Passing the same request.POST data to the unit test as I am in the runserver and live instance, which I verified via the debugger. Using a data dict instead of the actual request object. the is_valid() fails for two different forms on three fields (1 for one, 2 for the other). All three fields are choice fields. Dump of various relevant info is below. I appreciate any help anyone can offer. Thanks for your time, Chris FAIL: test discount, transaction, subscription ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/callen/Code/sellingstock/account/tests.py", line 170, in test_transact self.assertTrue(payment_form.is_valid()) AssertionError self.assertTrue(address_form.is_valid()) fails as well. Debugger info: AccountTest.data { " snipped data dict to only the fields that fail validation. " u'address-country': 226, u'address-state': 35, u'payment-type': 2 } payment_form._get_errors() Out[0]: {'type': [u'Select a valid choice. That choice is not one of the available choices.']} payment_form.is_valid() and address_form.is_valid() fail in the Unit Test. Relevant code is pasted below: type = forms.ModelChoiceField( queryset=CreditCardType.objects.filter(public=1) ) class AddressForm(ModelForm): """ What it says on the tin. """ class Meta: model = Address exclude = ('user', 'default', 'phone2', 'fax2',) class Address(models.Model): user = models.OneToOneField(User) street = models.CharField(max_length=150, blank=False, null=False, verbose_name = "Street Address") street2 = models.CharField(max_length=150, blank=True, null=False, verbose_name = "Street Address 2") city = models.CharField(max_length=150, blank=False, null=False) state = models.ForeignKey(State) zip = models.CharField(max_length=150, blank=False, null=False) country = models.ForeignKey(Country) phone = models.CharField(max_length=60, blank=True, null=True) phone2 = models.CharField(max_length=60, blank=True, null=True) fax = models.CharField(max_length=60, blank=True, null=True) fax2 = models.CharField(max_length=60, blank=True, null=True) def __unicode__(self): return self.street class Meta: ordering = ['-id'] verbose_name_plural = "Addresses" class State(models.Model): name = models.CharField(max_length=50) code = models.CharField(max_length=2) def __unicode__(self): return self.name class Country(models.Model): name = models.CharField(max_length=80) iso = models.CharField(max_length=2) iso3 = models.CharField(max_length=3) def __unicode__(self): return self.name --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---