Ticket #12224: diff#1224_withtestcases.diff
File diff#1224_withtestcases.diff, 3.6 KB (added by , 15 years ago) |
---|
-
django/contrib/auth/management/__init__.py
4 4 5 5 from django.db.models import get_models, signals 6 6 from django.contrib.auth import models as auth_app 7 from django.utils.encoding import force_unicode 7 8 8 9 def _get_permission_codename(action, opts): 9 10 return u'%s_%s' % (action, opts.object_name.lower()) … … 25 26 ctype = ContentType.objects.get_for_model(klass) 26 27 for codename, name in _get_all_permissions(klass._meta): 27 28 p, created = Permission.objects.get_or_create(codename=codename, content_type__pk=ctype.id, 28 defaults={'name': name, 'content_type': ctype})29 defaults={'name': force_unicode(name), 'content_type': ctype}) 29 30 if created and verbosity >= 2: 30 31 print "Adding permission '%s'" % p 31 32 -
tests/regressiontests/admin_scripts/tests.py
12 12 from django import conf, bin, get_version 13 13 from django.conf import settings 14 14 15 16 17 15 18 class AdminScriptTestCase(unittest.TestCase): 16 19 def write_settings(self, filename, apps=None, is_dir=False): 17 20 test_dir = os.path.dirname(os.path.dirname(__file__)) … … 21 24 settings_file = open(os.path.join(settings_dir,'__init__.py'), 'w') 22 25 else: 23 26 settings_file = open(os.path.join(test_dir, filename), 'w') 27 24 28 settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n') 25 29 exports = [ 26 30 'DATABASE_ENGINE', … … 1147 1151 out, err = self.run_manage(args) 1148 1152 self.assertNoOutput(err) 1149 1153 self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") 1154 1155 1156 1157 class SyncDB(AdminScriptTestCase): 1158 """Test for Parse of Unicode gettext_lazy issue with psycopg 1159 """ 1160 1161 def setUp(self): 1162 self.write_settings('settings.py') 1163 1164 def tearDown(self): 1165 self.remove_settings('settings.py') 1166 1167 def test_psyco( self ): 1168 "Using gettext_lazy can then calling syncdb will cause an error with psycopg2" 1169 args = [ 'syncdb','--settings=settings','--noinput' ] 1170 out,err = self.run_django_admin(args) 1171 self.assertNoOutput(err) 1172 1173 -
tests/regressiontests/admin_scripts/models.py
1 1 from django.db import models 2 from django.utils.translation import ugettext_lazy 2 3 3 4 class Article(models.Model): 4 5 headline = models.CharField(max_length=100, default='Default headline') … … 9 10 10 11 class Meta: 11 12 ordering = ('-pub_date', 'headline') 12 13 No newline at end of file 13 14 15 16 # used to test the pyco problem with syndb (SyncDB test class) 17 class Person( models.Model ): 18 class Meta: 19 permissions = ( ('can_view_info', ugettext_lazy("Can view info.")), ) 20 21 No newline at end of file