From 65220a4a9b6480aa127a8e03748df206b94da43b Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Fri, 5 Jun 2015 13:33:47 +0100 Subject: [PATCH] Failing test for #1265 --- wagtail/wagtailcore/tests/test_page_model.py | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/wagtail/wagtailcore/tests/test_page_model.py b/wagtail/wagtailcore/tests/test_page_model.py index 814d460b0..628adc8d6 100644 --- a/wagtail/wagtailcore/tests/test_page_model.py +++ b/wagtail/wagtailcore/tests/test_page_model.py @@ -1,5 +1,6 @@ import datetime import json +import unittest import pytz @@ -677,3 +678,27 @@ class TestIssue756(TestCase): # Check that latest_revision_created_at is still set self.assertIsNotNone(Page.objects.get(id=1).latest_revision_created_at) + + +class TestPageProxy(TestCase): + @unittest.expectedFailure + def test_page_proxy(self): + from django.apps import apps + wagtailcore_models = apps.all_models['wagtailcore'].copy() + + try: + # See #1265 + # Proxy models can sometimes return None from their _meta.get_fields method + # This caused the check method to break as it didn't expect this + class PageProxy(Page): + class Meta: + proxy = True + app_label = 'wagtailcore' + + # Shouldn't raise an error + PageProxy.check() + finally: + # Django registers models as they're initialised + # Unregister PageProxy to prevent breaking the migrations test + apps.all_models['wagtailcore'] = wagtailcore_models + apps.clear_cache()