Fixed #22906 -- Added a more helpful repr to migrations' ModelState.

Thanks Collin Anderson for the report and original patch.
This commit is contained in:
Loic Bistuer 2014-07-06 13:57:23 +07:00
parent 32fefc6f70
commit 2572c07cc6
2 changed files with 13 additions and 0 deletions

View file

@ -420,3 +420,13 @@ class ModelStateTests(TestCase):
state = ModelState('app', 'Model', [('name', field)])
Model = state.render(apps)
self.assertNotEqual(Model._meta.get_field('name'), field)
def test_repr(self):
field = models.CharField(max_length=1)
state = ModelState('app', 'Model', [('name', field)], bases=['app.A', 'app.B', 'app.C'])
self.assertEqual(repr(state), "<ModelState: 'app.Model'>")
project_state = ProjectState()
project_state.add_model_state(state)
with self.assertRaisesMessage(InvalidBasesError, "Cannot resolve bases for [<ModelState: 'app.Model'>]"):
project_state.render()