diff --git a/test_project/polls/fixtures/polls_testmaker.json b/test_project/polls/fixtures/polls_testmaker.json index 6b16094..bbdc817 100644 --- a/test_project/polls/fixtures/polls_testmaker.json +++ b/test_project/polls/fixtures/polls_testmaker.json @@ -1,73 +1,73 @@ [ { - "pk": 1, - "model": "polls.poll", + "pk": 1, + "model": "polls.poll", "fields": { - "pub_date": "2007-04-01 00:00:00", - "question": "What's up?", + "pub_date": "2007-04-01 00:00:00", + "question": "What's up?", "slug": "whats-up" } - }, + }, { - "pk": 2, - "model": "polls.poll", + "pk": 2, + "model": "polls.poll", "fields": { - "pub_date": "2009-04-25 21:46:44", - "question": "Test poll", + "pub_date": "2009-04-25 21:46:44", + "question": "Test poll", "slug": "test-poll" } - }, + }, { - "pk": 1, - "model": "polls.choice", + "pk": 1, + "model": "polls.choice", "fields": { - "votes": 3, - "poll": 1, + "votes": 3, + "poll": 1, "choice": "Just hacking again" } - }, + }, { - "pk": 2, - "model": "polls.choice", + "pk": 2, + "model": "polls.choice", "fields": { - "votes": 2, - "poll": 1, + "votes": 2, + "poll": 1, "choice": "Playing with fire" } - }, + }, { - "pk": 3, - "model": "polls.choice", + "pk": 3, + "model": "polls.choice", "fields": { - "votes": 0, - "poll": 1, + "votes": 0, + "poll": 1, "choice": "Clapping my shoes together three times" } - }, + }, { - "pk": 4, - "model": "polls.choice", + "pk": 4, + "model": "polls.choice", "fields": { - "votes": 0, - "poll": 2, + "votes": 0, + "poll": 2, "choice": "Choice 1 " } - }, + }, { - "pk": 5, - "model": "polls.choice", + "pk": 5, + "model": "polls.choice", "fields": { - "votes": 3, - "poll": 2, + "votes": 3, + "poll": 2, "choice": "Choice too" } - }, + }, { - "pk": 6, - "model": "polls.choice", + "pk": 6, + "model": "polls.choice", "fields": { - "votes": 0, - "poll": 2, + "votes": 0, + "poll": 2, "choice": "New Choice" } } diff --git a/test_utils/management/commands/makefixture.py b/test_utils/management/commands/makefixture.py index 34a2792..b3ff2bc 100644 --- a/test_utils/management/commands/makefixture.py +++ b/test_utils/management/commands/makefixture.py @@ -81,24 +81,24 @@ def handle_reverse(self, **options): related_set_name, model_name)) to_reverse.setdefault(model, []).append(related_set_name) return to_reverse - + def handle_models(self, models, **options): format = options.get('format','json') indent = options.get('indent',None) show_traceback = options.get('traceback', False) propagate = options.get('propagate', True) follow_reverse = self.handle_reverse(**options) - + # Check that the serialization format exists; this is a shortcut to # avoid collating all the objects and _then_ failing. if format not in serializers.get_public_serializer_formats(): raise CommandError("Unknown serialization format: %s" % format) - + try: serializers.get_serializer(format) except KeyError: raise CommandError("Unknown serialization format: %s" % format) - + objects = [] for model, slice in models: if isinstance(slice, basestring): @@ -113,7 +113,7 @@ def handle_models(self, models, **options): objects.extend(items) else: raise CommandError("Wrong slice: %s" % slice) - + all = objects if propagate: collected = set([(x.__class__, x.pk) for x in all]) @@ -134,7 +134,7 @@ def handle_models(self, models, **options): if new and not (new.__class__, new.pk) in collected: collected.add((new.__class__, new.pk)) related.append(new) - # follow reverse relations as requested + # follow reverse relations as requested for reverse_field in follow_reverse.get(x.__class__, []): mgr = getattr(x, reverse_field) for new in mgr.all(): @@ -143,7 +143,7 @@ def handle_models(self, models, **options): related.append(new) objects = related all.extend(objects) - + try: return serializers.serialize(format, all, indent=indent) except Exception, e: @@ -156,7 +156,7 @@ def get_models(self): def get_model_from_name(self, search): """Given a name of a model, return the model object associated with it - + The name can be either fully specified or uniquely matching the end of the model name. e.g. django.contrib.auth.User diff --git a/test_utils/testmaker/processors/base.py b/test_utils/testmaker/processors/base.py index 3baab99..f9c8fa7 100644 --- a/test_utils/testmaker/processors/base.py +++ b/test_utils/testmaker/processors/base.py @@ -116,7 +116,7 @@ def _log_context(self, context): keys += self._get_context_keys(context) keys = set(keys) - # Skip some keys + # Skip some keys for discardkey in DISCARD_CONTEXT_KEYS: keys.discard(discardkey)