def test_isalphanumeric(self): chemical = Chemical(bnf_code='0+9', chem_name='Test') with self.assertRaises(ValidationError): if chemical.full_clean(): chemical.save() self.assertEqual(Chemical.objects.filter(bnf_code='0+9').count(), 0) chemical = Chemical(bnf_code='09', chem_name='Test') chemical.full_clean() chemical.save() self.assertEqual(Chemical.objects.filter(bnf_code='09').count(), 1)