@@ -43,9 +43,9 @@ def test_default_values():
43
43
field = _convert_field_from_spec ("s" , "hi" )
44
44
assert field is not None
45
45
assert isinstance (field , graphene .Field )
46
- # there's a default value, so it's not required
47
- assert not isinstance (field .type , graphene .NonNull )
48
- assert field .type == graphene .String
46
+ # there's a default value, so it never null
47
+ assert isinstance (field .type , graphene .NonNull )
48
+ assert field .type . of_type == graphene .String
49
49
assert field .default_value == "hi"
50
50
51
51
@@ -65,15 +65,15 @@ def test_default_values():
65
65
def test_builtin_scalars (input , expected ):
66
66
field = _convert_field_from_spec ("attr" , input )
67
67
assert isinstance (field , graphene .Field )
68
- assert field .type == expected
68
+ assert field .type . of_type == expected
69
69
assert field .default_value == input [1 ]
70
70
71
71
72
72
def test_union ():
73
73
field = _convert_field_from_spec ("attr" , (T .Union [int , float , str ], 5.0 ))
74
- assert issubclass (field .type , graphene .Union )
74
+ assert issubclass (field .type . of_type , graphene .Union )
75
75
assert field .default_value == 5.0
76
- assert field .type .__name__ .startswith ("UnionOf" )
76
+ assert field .type .of_type . __name__ .startswith ("UnionOf" )
77
77
78
78
79
79
if sys .version_info >= (3 , 8 ):
@@ -83,15 +83,15 @@ def test_literal():
83
83
field = _convert_field_from_spec (
84
84
"attr" , (T .Literal ["literal1" , "literal2" , 3 ], 3 )
85
85
)
86
- assert issubclass (field .type , graphene .Union )
86
+ assert issubclass (field .type . of_type , graphene .Union )
87
87
assert field .default_value == 3
88
- assert field .type .__name__ .startswith ("UnionOf" )
88
+ assert field .type .of_type . __name__ .startswith ("UnionOf" )
89
89
90
90
def test_literal_singleton ():
91
91
field = _convert_field_from_spec ("attr" , (T .Literal ["literal1" ], "literal1" ))
92
- assert issubclass (field .type , graphene .String )
92
+ assert issubclass (field .type . of_type , graphene .String )
93
93
assert field .default_value == "literal1"
94
- assert field .type == graphene .String
94
+ assert field .type . of_type == graphene .String
95
95
96
96
97
97
def test_mapping ():
@@ -103,34 +103,34 @@ def test_mapping():
103
103
def test_decimal (monkeypatch ):
104
104
monkeypatch .setattr (converters , "DECIMAL_SUPPORTED" , True )
105
105
field = _convert_field_from_spec ("attr" , (decimal .Decimal , decimal .Decimal (1.25 )))
106
- assert field .type .__name__ == "Decimal"
106
+ assert field .type .of_type . __name__ == "Decimal"
107
107
108
108
monkeypatch .setattr (converters , "DECIMAL_SUPPORTED" , False )
109
109
field = _convert_field_from_spec ("attr" , (decimal .Decimal , decimal .Decimal (1.25 )))
110
- assert field .type .__name__ == "Float"
110
+ assert field .type .of_type . __name__ == "Float"
111
111
112
112
113
113
def test_iterables ():
114
114
field = _convert_field_from_spec ("attr" , (T .List [int ], [1 , 2 ]))
115
- assert isinstance (field .type , graphene .types .List )
115
+ assert isinstance (field .type . of_type , graphene .types .List )
116
116
117
117
field = _convert_field_from_spec ("attr" , (list , [1 , 2 ]))
118
- assert field .type == graphene .types .List
118
+ assert field .type . of_type == graphene .types .List
119
119
120
120
field = _convert_field_from_spec ("attr" , (T .Set [int ], {1 , 2 }))
121
- assert isinstance (field .type , graphene .types .List )
121
+ assert isinstance (field .type . of_type , graphene .types .List )
122
122
123
123
field = _convert_field_from_spec ("attr" , (set , {1 , 2 }))
124
- assert field .type == graphene .types .List
124
+ assert field .type . of_type == graphene .types .List
125
125
126
126
field = _convert_field_from_spec ("attr" , (T .Tuple [int , float ], (1 , 2.2 )))
127
- assert isinstance (field .type , graphene .types .List )
127
+ assert isinstance (field .type . of_type , graphene .types .List )
128
128
129
129
field = _convert_field_from_spec ("attr" , (T .Tuple [int , ...], (1 , 2.2 )))
130
- assert isinstance (field .type , graphene .types .List )
130
+ assert isinstance (field .type . of_type , graphene .types .List )
131
131
132
132
field = _convert_field_from_spec ("attr" , (tuple , (1 , 2 )))
133
- assert field .type == graphene .types .List
133
+ assert field .type . of_type == graphene .types .List
134
134
135
135
field = _convert_field_from_spec ("attr" , (T .Union [None , int ], 1 ))
136
136
assert field .type == graphene .types .Int
@@ -142,8 +142,8 @@ class Color(enum.Enum):
142
142
GREEN = 2
143
143
144
144
field = _convert_field_from_spec ("attr" , (Color , Color .RED ))
145
- assert field .type .__name__ == "Color"
146
- assert field .type ._meta .enum == Color
145
+ assert field .type .of_type . __name__ == "Color"
146
+ assert field .type .of_type . _meta .enum == Color
147
147
148
148
149
149
def test_existing_model ():
@@ -157,7 +157,7 @@ class Meta:
157
157
model = Foo
158
158
159
159
field = _convert_field_from_spec ("attr" , (Foo , Foo (name = "bar" )))
160
- assert field .type == GraphFoo
160
+ assert field .type . of_type == GraphFoo
161
161
162
162
163
163
def test_unresolved_placeholders ():
0 commit comments