Ticket #12224: diff#1224_withtestcases.diff

File diff#1224_withtestcases.diff, 3.6 KB (added by cscortes, 14 years ago)

Has patches and tests

  • django/contrib/auth/management/__init__.py

     
    44
    55from django.db.models import get_models, signals
    66from django.contrib.auth import models as auth_app
     7from django.utils.encoding import force_unicode
    78
    89def _get_permission_codename(action, opts):
    910    return u'%s_%s' % (action, opts.object_name.lower())
     
    2526        ctype = ContentType.objects.get_for_model(klass)
    2627        for codename, name in _get_all_permissions(klass._meta):
    2728            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})
    2930            if created and verbosity >= 2:
    3031                print "Adding permission '%s'" % p
    3132
  • tests/regressiontests/admin_scripts/tests.py

     
    1212from django import conf, bin, get_version
    1313from django.conf import settings
    1414
     15
     16
     17
    1518class AdminScriptTestCase(unittest.TestCase):
    1619    def write_settings(self, filename, apps=None, is_dir=False):
    1720        test_dir = os.path.dirname(os.path.dirname(__file__))
     
    2124            settings_file = open(os.path.join(settings_dir,'__init__.py'), 'w')
    2225        else:
    2326            settings_file = open(os.path.join(test_dir, filename), 'w')
     27           
    2428        settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
    2529        exports = [
    2630            'DATABASE_ENGINE',
     
    11471151        out, err = self.run_manage(args)
    11481152        self.assertNoOutput(err)
    11491153        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
     1157class 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

     
    11from django.db import models
     2from django.utils.translation import ugettext_lazy
    23
    34class Article(models.Model):
    45    headline = models.CharField(max_length=100, default='Default headline')
     
    910
    1011    class Meta:
    1112        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)
     17class Person( models.Model ):
     18    class Meta:                                 
     19        permissions = ( ('can_view_info', ugettext_lazy("Can view info.")), )
     20   
     21 No newline at end of file
Back to Top