1
+ import pytest
1
2
import typing as t
2
3
import os
3
4
from enum import Enum , Flag
@@ -77,17 +78,19 @@ def test_admin_change_display_bug35(self):
77
78
78
79
79
80
class _GenericAdminFormTest (StaticLiveServerTestCase ):
80
- MODEL_CLASS : Model
81
+ MODEL_CLASS : t . Type [ Model ]
81
82
82
83
HEADLESS = True
83
84
84
85
__test__ = False
85
86
86
- def enum (self , field ):
87
- return self .MODEL_CLASS ._meta .get_field (field ).enum
87
+ def enum (self , field : str ) -> t .Type [Enum ]:
88
+ enum = t .cast (EnumField , self .MODEL_CLASS ._meta .get_field (field )).enum
89
+ assert enum
90
+ return enum
88
91
89
92
@property
90
- def changes (self ) -> t .List [t .Dict [str , Enum ]]:
93
+ def changes (self ) -> t .List [t .Dict [str , t . Any ]]:
91
94
# must implement
92
95
return [{}]
93
96
@@ -205,10 +208,10 @@ def verify_changes(self, obj: Model, expected: t.Dict[str, t.Any]):
205
208
)
206
209
except AssertionError :
207
210
if connection .vendor == "oracle" and issubclass (
208
- field .enum , Flag
211
+ self .enum ( field . name ) , Flag
209
212
):
210
213
# TODO - why is oracle returning 0 instead of None?
211
- self .assertEqual (obj_val , field .enum (0 ))
214
+ self .assertEqual (obj_val , self .enum ( field . name ) (0 ))
212
215
else :
213
216
raise
214
217
else :
@@ -287,7 +290,7 @@ class TestEnumTesterAdminForm(EnumTypeMixin, _GenericAdminFormTest):
287
290
__test__ = True
288
291
289
292
@property
290
- def changes (self ) -> t .Dict [str , Enum ]:
293
+ def changes (self ) -> t .List [ t . Dict [str , t . Any ] ]:
291
294
return [
292
295
{},
293
296
{
@@ -319,7 +322,7 @@ class TestNullBlankAdminBehavior(_GenericAdminFormTest):
319
322
__test__ = True
320
323
321
324
@property
322
- def changes (self ) -> t .Dict [str , Enum ]:
325
+ def changes (self ) -> t .List [ t . Dict [str , t . Any ] ]:
323
326
return [
324
327
{"required" : ExternEnum .THREE , "blank" : ExternEnum .TWO },
325
328
{
@@ -346,13 +349,16 @@ def changes(self) -> t.Dict[str, Enum]:
346
349
]
347
350
348
351
352
+ @pytest .mark .skipif (
353
+ connection .vendor == "oracle" , reason = "Null/blank form behavior on oracle broken"
354
+ )
349
355
class TestNullableBlankAdminBehavior (_GenericAdminFormTest ):
350
356
MODEL_CLASS = NullableBlankFormTester
351
357
__test__ = True
352
358
HEADLESS = True
353
359
354
360
@property
355
- def changes (self ) -> t .Dict [str , Enum ]:
361
+ def changes (self ) -> t .List [ t . Dict [str , t . Any ] ]:
356
362
return [
357
363
{"required" : NullableExternEnum .THREE , "blank" : NullableExternEnum .TWO },
358
364
{
@@ -379,13 +385,16 @@ def changes(self) -> t.Dict[str, Enum]:
379
385
]
380
386
381
387
388
+ @pytest .mark .skipif (
389
+ connection .vendor == "oracle" , reason = "Null/blank form behavior on oracle broken"
390
+ )
382
391
class TestNullableStrAdminBehavior (_GenericAdminFormTest ):
383
392
MODEL_CLASS = NullableStrFormTester
384
393
__test__ = True
385
394
HEADLESS = True
386
395
387
396
@property
388
- def changes (self ) -> t .Dict [str , Enum ]:
397
+ def changes (self ) -> t .List [ t . Dict [str , t . Any ] ]:
389
398
return [
390
399
{"required" : NullableStrEnum .STR1 , "blank" : NullableStrEnum .STR2 },
391
400
{
@@ -417,7 +426,7 @@ class TestBug53AdminBehavior(_GenericAdminFormTest):
417
426
__test__ = True
418
427
419
428
@property
420
- def changes (self ) -> t .Dict [str , Enum ]:
429
+ def changes (self ) -> t .List [ t . Dict [str , t . Any ] ]:
421
430
return [
422
431
{
423
432
"char_blank_null_false" : StrTestEnum .V2 ,
0 commit comments