File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,16 @@ def convert_choice_name(name):
27
27
28
28
29
29
def get_choices (choices ):
30
+ converted_names = []
30
31
for value , help_text in choices :
31
32
if isinstance (help_text , (tuple , list )):
32
33
for choice in get_choices (help_text ):
33
34
yield choice
34
35
else :
35
36
name = convert_choice_name (value )
37
+ while name in converted_names :
38
+ name += '_' + str (len (converted_names ))
39
+ converted_names .append (name )
36
40
description = help_text
37
41
yield name , value , description
38
42
Original file line number Diff line number Diff line change @@ -176,6 +176,22 @@ class Meta:
176
176
convert_django_field_with_choices (field )
177
177
178
178
179
+ def test_field_with_choices_collision ():
180
+ field = models .CharField (help_text = 'Timezone' , choices = (
181
+ ('Etc/GMT+1+2' , 'Fake choice to produce double collision' ),
182
+ ('Etc/GMT+1' , 'Greenwich Mean Time +1' ),
183
+ ('Etc/GMT-1' , 'Greenwich Mean Time -1' ),
184
+ ))
185
+
186
+ class CollisionChoicesModel (models .Model ):
187
+ timezone = field
188
+
189
+ class Meta :
190
+ app_label = 'test'
191
+
192
+ convert_django_field_with_choices (field )
193
+
194
+
179
195
def test_should_float_convert_float ():
180
196
assert_conversion (models .FloatField , graphene .Float )
181
197
You can’t perform that action at this time.
0 commit comments