File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""Tests for mailing app forms."""
22from django .test import TestCase
3+ from django .contrib .contenttypes .models import ContentType
34
45from mailing .tests .forms import TestBaseEmailTemplateForm
56
@@ -13,6 +14,10 @@ def setUp(self):
1314 "internal_name" : "notification 01" ,
1415 }
1516
17+ def tearDown (self ):
18+ super ().tearDown ()
19+ ContentType .objects .clear_cache ()
20+
1621 def test_validate_required_fields (self ):
1722 required = set (self .data )
1823 form = TestBaseEmailTemplateForm (data = {})
Original file line number Diff line number Diff line change 6363REST_FRAMEWORK ['DEFAULT_RENDERER_CLASSES' ] += (
6464 'rest_framework.renderers.BrowsableAPIRenderer' ,
6565)
66+
67+ BAKER_CUSTOM_CLASS = "pydotorg.tests.baker.PolymorphicAwareBaker"
Original file line number Diff line number Diff line change 1+ from polymorphic .models import PolymorphicModel
2+ from model_bakery import baker
3+
4+
5+ class PolymorphicAwareBaker (baker .Baker ):
6+ """
7+ Our custom model baker ignores the polymorphic_ctype field on all polymorphic
8+ models - this allows the base class to set it correctly.
9+
10+ See https://github.com/python/pythondotorg/issues/2567
11+ """
12+
13+ def get_fields (self ):
14+ fields = super ().get_fields ()
15+ if issubclass (self .model , PolymorphicModel ):
16+ fields = {field for field in fields if field .name != "polymorphic_ctype" }
17+ return fields
You can’t perform that action at this time.
0 commit comments