File tree 3 files changed +11
-9
lines changed
3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -32,14 +32,14 @@ def deserialize(self, value):
32
32
return deserializer (value )
33
33
34
34
def cast (self , value ):
35
- if not self .schema :
36
- return value
37
-
38
35
try :
39
36
deserialized = self .deserialize (value )
40
37
except ValueError as exc :
41
38
raise InvalidMediaTypeValue (exc )
42
39
40
+ if not self .schema :
41
+ return value
42
+
43
43
try :
44
44
return self .schema .cast (deserialized )
45
45
except CastError as exc :
Original file line number Diff line number Diff line change @@ -99,14 +99,14 @@ def cast(self, value):
99
99
not self .allow_empty_value ):
100
100
raise EmptyParameterValue (self .name )
101
101
102
- if not self .schema :
103
- return value
104
-
105
102
try :
106
103
deserialized = self .deserialize (value )
107
104
except (ValueError , AttributeError ) as exc :
108
105
raise InvalidParameterValue (self .name , exc )
109
106
107
+ if not self .schema :
108
+ return value
109
+
110
110
try :
111
111
return self .schema .cast (deserialized )
112
112
except CastError as exc :
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from openapi_core .schema .media_types .exceptions import InvalidMediaTypeValue
1
4
from openapi_core .schema .media_types .models import MediaType
2
5
3
6
@@ -7,6 +10,5 @@ def test_empty(self):
7
10
media_type = MediaType ('application/json' )
8
11
value = ''
9
12
10
- result = media_type .cast (value )
11
-
12
- assert result == value
13
+ with pytest .raises (InvalidMediaTypeValue ):
14
+ media_type .cast (value )
You can’t perform that action at this time.
0 commit comments