File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ """Collection of project wide decorators."""
12import functools
23import logging
4+ import warnings
35
46try :
57 import wtforms # noqa
@@ -23,3 +25,25 @@ def wrapped(*args, **kwargs):
2325 return func (* args , ** kwargs )
2426
2527 return wrapped
28+
29+
30+ def orm_deprecated (func ):
31+ """Warning about usage of deprecated functions, that will be removed in the future."""
32+
33+ @functools .wraps (func )
34+ def wrapped (* args , ** kwargs ):
35+ # TODO: Insert URL
36+ warnings .warn (
37+ (
38+ f"ORM module and function '{ func .__name__ } ' are deprecated and will be "
39+ "removed in version 3.0.0. Please switch to form generation from full "
40+ "model nesting. Support and bugfixes are not available for stalled code. "
41+ "Please read: "
42+ ),
43+ DeprecationWarning ,
44+ stacklevel = 2 ,
45+ )
46+
47+ return func (* args , ** kwargs )
48+
49+ return wrapped
Original file line number Diff line number Diff line change 1+ """Tests for project wide decorators."""
2+ from flask_mongoengine .decorators import orm_deprecated
3+
4+
5+ def test__orm_deprecated (recwarn ):
6+ @orm_deprecated
7+ def func (a , b ):
8+ """Function example."""
9+ return a + b
10+
11+ assert func (1 , 1 ) == 2
12+ assert str (recwarn .list [0 ].message ) == (
13+ "ORM module and function 'func' are deprecated and will be removed in version 3.0.0. "
14+ "Please switch to form generation from full model nesting. "
15+ "Support and bugfixes are not available for stalled code. "
16+ "Please read: "
17+ )
You can’t perform that action at this time.
0 commit comments