From bdae3cc27d673feefed0a24fa9248256b53ef85a Mon Sep 17 00:00:00 2001 From: Karen Tracey Date: Sun, 16 Nov 2008 19:08:53 +0000 Subject: [1.0.X] Fixed #9608: Ensured a Model's default repr() is printable even if its unicode method raises a Unicode error. r9475 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9477 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/model_regress/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/model_regress/models.py b/tests/regressiontests/model_regress/models.py index 19d38b216c..3c87e1c1e9 100644 --- a/tests/regressiontests/model_regress/models.py +++ b/tests/regressiontests/model_regress/models.py @@ -46,6 +46,12 @@ class Worker(models.Model): def __unicode__(self): return self.name +class BrokenUnicodeMethod(models.Model): + name = models.CharField(max_length=7) + def __unicode__(self): + return 'Názov: %s' % self.name + + __test__ = {'API_TESTS': """ (NOTE: Part of the regression test here is merely parsing the model declaration. The verbose_name, in particular, did not always work.) @@ -128,5 +134,11 @@ datetime.datetime(2000, 1, 1, 6, 1, 1) >>> w +# Models with broken unicode methods should still have a printable repr +>>> b = BrokenUnicodeMethod(name="Jerry") +>>> b.save() +>>> BrokenUnicodeMethod.objects.all() +[] + """ } -- cgit v1.3