File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ docs = [
45
45
" alabaster==1.0.0" ,
46
46
]
47
47
tests = [
48
+ " packaging>=24.2" ,
48
49
" pytest==8.3.5" ,
49
50
" pytest-cov==6.0.0" ,
50
51
" coverage==7.6.12" ,
Original file line number Diff line number Diff line change
1
+ import importlib .metadata
1
2
from collections import namedtuple
2
3
3
4
import pytest
6
7
7
8
import marshmallow as ma
8
9
10
+ from packaging .version import Version
11
+
9
12
from .mocks import DatabaseMock
10
13
14
+ MA_VERSION = Version (importlib .metadata .version ("marshmallow" ))
15
+
11
16
12
17
class AppConfig :
13
18
"""Base application configuration class
@@ -36,6 +41,12 @@ def app(request):
36
41
return _app
37
42
38
43
44
+ if MA_VERSION .major >= 4 :
45
+ pass_collection_true_kwargs = {"pass_collection" : True }
46
+ else :
47
+ pass_collection_true_kwargs = {"pass_many" : True }
48
+
49
+
39
50
class CounterSchema (ma .Schema ):
40
51
"""Base Schema with load/dump counters"""
41
52
@@ -50,12 +61,12 @@ def reset_load_count(cls):
50
61
def reset_dump_count (cls ):
51
62
cls .dump_count = 0
52
63
53
- @ma .post_load (pass_many = True )
64
+ @ma .post_load (** pass_collection_true_kwargs )
54
65
def increment_load_count (self , data , ** kwargs ):
55
66
self .__class__ .load_count += 1
56
67
return data
57
68
58
- @ma .post_dump (pass_many = True )
69
+ @ma .post_dump (** pass_collection_true_kwargs )
59
70
def increment_dump_count (self , data , ** kwargs ):
60
71
self .__class__ .dump_count += 1
61
72
return data
You can’t perform that action at this time.
0 commit comments