Ticket #18196: 18196-2.diff

File 18196-2.diff, 3.9 KB (added by Claude Paroz, 12 years ago)

Updated to current trunk

  • django/core/management/commands/loaddata.py

    diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
    index 34f8041..f42dfb0 100644
    a b class Command(BaseCommand):  
    196196                                    loaded_object_count += loaded_objects_in_fixture
    197197                                    fixture_object_count += objects_in_fixture
    198198                                    label_found = True
     199                                except Exception as e:
     200                                    if not isinstance(e, CommandError):
     201                                        e.args = ("Problem installing fixture '%s': %s" % (full_path, e),)
     202                                    raise
    199203                                finally:
    200204                                    fixture.close()
    201205
    class Command(BaseCommand):  
    209213            # Since we disabled constraint checks, we must manually check for
    210214            # any invalid keys that might have been added
    211215            table_names = [model._meta.db_table for model in models]
    212             connection.check_constraints(table_names=table_names)
     216            try:
     217                connection.check_constraints(table_names=table_names)
     218            except Exception as e:
     219                e.args = ("Problem installing fixtures: %s" % e,)
     220                raise
    213221
    214222        except (SystemExit, KeyboardInterrupt):
    215223            raise
    class Command(BaseCommand):  
    217225            if commit:
    218226                transaction.rollback(using=using)
    219227                transaction.leave_transaction_management(using=using)
    220             if not isinstance(e, CommandError):
    221                 e.args = ("Problem installing fixture '%s': %s" % (full_path, e),)
    222228            raise
    223229
    224230        # If we found even one object in a fixture, we need to reset the
  • django/test/signals.py

    diff --git a/django/test/signals.py b/django/test/signals.py
    index 052b7df..5b0a9a1 100644
    a b import time  
    44from django.conf import settings
    55from django.db import connections
    66from django.dispatch import receiver, Signal
    7 from django.template import context
    87from django.utils import timezone
    98
    109template_rendered = Signal(providing_args=["template", "context"])
    def update_connections_time_zone(**kwargs):  
    4847@receiver(setting_changed)
    4948def clear_context_processors_cache(**kwargs):
    5049    if kwargs['setting'] == 'TEMPLATE_CONTEXT_PROCESSORS':
     50        from django.template import context
    5151        context._standard_context_processors = None
    5252
    5353
    5454@receiver(setting_changed)
     55def clear_serializers_cache(**kwargs):
     56    if kwargs['setting'] == 'SERIALIZATION_MODULES':
     57        from django.core import serializers
     58        serializers._serializers = {}
     59
     60
     61@receiver(setting_changed)
    5562def language_changed(**kwargs):
    5663    if kwargs['setting'] in ('LOCALE_PATHS', 'LANGUAGE_CODE'):
    5764        from django.utils.translation import trans_real
  • tests/regressiontests/fixtures_regress/tests.py

    diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
    index ab93341..7ffb2af 100644
    a b class TestFixtures(TestCase):  
    126126                commit=False,
    127127            )
    128128
     129    @override_settings(SERIALIZATION_MODULES={'unkn': 'unexistent.path'})
     130    def test_unimportable_serializer(self):
     131        """
     132        Test that failing serializer import raises the proper error
     133        """
     134        with self.assertRaisesRegexp(ImportError,
     135                "No module named unexistent.path"):
     136            management.call_command(
     137                'loaddata',
     138                'bad_fixture1.unkn',
     139                verbosity=0,
     140                commit=False,
     141            )
     142
    129143    def test_invalid_data(self):
    130144        """
    131145        Test for ticket #4371 -- Loading a fixture file with invalid data
Back to Top