File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
See https://www.python-ldap.org/ for details.
7
7
"""
8
+ import warnings
8
9
9
10
from ldap import __version__
10
11
@@ -62,6 +63,11 @@ def strlist_minus(a,b):
62
63
Return list of all items in a which are not in b (a - b).
63
64
a,b are supposed to be lists of case-insensitive strings.
64
65
"""
66
+ warnings .warn (
67
+ "strlist functions are deprecated and will be removed in 3.4" ,
68
+ category = DeprecationWarning ,
69
+ stacklevel = 2 ,
70
+ )
65
71
temp = cidict ()
66
72
for elt in b :
67
73
temp [elt ] = elt
@@ -77,6 +83,11 @@ def strlist_intersection(a,b):
77
83
"""
78
84
Return intersection of two lists of case-insensitive strings a,b.
79
85
"""
86
+ warnings .warn (
87
+ "strlist functions are deprecated and will be removed in 3.4" ,
88
+ category = DeprecationWarning ,
89
+ stacklevel = 2 ,
90
+ )
80
91
temp = cidict ()
81
92
for elt in a :
82
93
temp [elt ] = elt
@@ -92,6 +103,11 @@ def strlist_union(a,b):
92
103
"""
93
104
Return union of two lists of case-insensitive strings a,b.
94
105
"""
106
+ warnings .warn (
107
+ "strlist functions are deprecated and will be removed in 3.4" ,
108
+ category = DeprecationWarning ,
109
+ stacklevel = 2 ,
110
+ )
95
111
temp = cidict ()
96
112
for elt in a :
97
113
temp [elt ] = elt
Original file line number Diff line number Diff line change 7
7
8
8
import os
9
9
import unittest
10
+ import warnings
10
11
11
12
# Switch off processing .ldaprc or ldap.conf before importing _ldap
12
13
os .environ ['LDAPNOINIT' ] = '1'
@@ -48,6 +49,19 @@ def test_cidict(self):
48
49
self .assertEqual (cix .has_key ("abcdef" ), False )
49
50
self .assertEqual (cix .has_key ("AbCDef" ), False )
50
51
52
+ def test_strlist_deprecated (self ):
53
+ strlist_funcs = [
54
+ ldap .cidict .strlist_intersection ,
55
+ ldap .cidict .strlist_minus ,
56
+ ldap .cidict .strlist_union
57
+ ]
58
+ for strlist_func in strlist_funcs :
59
+ with warnings .catch_warnings (record = True ) as w :
60
+ warnings .resetwarnings ()
61
+ warnings .simplefilter ("always" , DeprecationWarning )
62
+ strlist_func (["a" ], ["b" ])
63
+ self .assertEqual (len (w ), 1 )
64
+
51
65
52
66
if __name__ == '__main__' :
53
67
unittest .main ()
You can’t perform that action at this time.
0 commit comments