@@ -99,12 +99,6 @@ def _open_conn(self, bind=True):
99
99
self .assertEqual (type (msgid ), type (0 ))
100
100
return l
101
101
102
- def assertNotNone (self , expr , msg = None ):
103
- self .assertFalse (expr is None , msg or repr (expr ))
104
-
105
- def assertNone (self , expr , msg = None ):
106
- self .assertFalse (expr is not None , msg or repr (expr ))
107
-
108
102
# Test for the existence of a whole bunch of constants
109
103
# that the C module is supposed to export
110
104
def test_constants (self ):
@@ -128,88 +122,88 @@ def test_constants(self):
128
122
self .assertEqual (_ldap .RES_SEARCH_REFERENCE , 0x73 ) # v3
129
123
self .assertEqual (_ldap .RES_EXTENDED , 0x78 ) # v3
130
124
#self.assertEqual(_ldap.RES_INTERMEDIATE, 0x79) # v3
131
- self .assertNotNone (_ldap .RES_ANY )
132
- self .assertNotNone (_ldap .RES_UNSOLICITED )
125
+ self .assertIsNotNone (_ldap .RES_ANY )
126
+ self .assertIsNotNone (_ldap .RES_UNSOLICITED )
133
127
134
- self .assertNotNone (_ldap .AUTH_NONE )
135
- self .assertNotNone (_ldap .AUTH_SIMPLE )
128
+ self .assertIsNotNone (_ldap .AUTH_NONE )
129
+ self .assertIsNotNone (_ldap .AUTH_SIMPLE )
136
130
137
- self .assertNotNone (_ldap .SCOPE_BASE )
138
- self .assertNotNone (_ldap .SCOPE_ONELEVEL )
139
- self .assertNotNone (_ldap .SCOPE_SUBTREE )
131
+ self .assertIsNotNone (_ldap .SCOPE_BASE )
132
+ self .assertIsNotNone (_ldap .SCOPE_ONELEVEL )
133
+ self .assertIsNotNone (_ldap .SCOPE_SUBTREE )
140
134
141
- self .assertNotNone (_ldap .MOD_ADD )
142
- self .assertNotNone (_ldap .MOD_DELETE )
143
- self .assertNotNone (_ldap .MOD_REPLACE )
144
- self .assertNotNone (_ldap .MOD_INCREMENT )
145
- self .assertNotNone (_ldap .MOD_BVALUES )
135
+ self .assertIsNotNone (_ldap .MOD_ADD )
136
+ self .assertIsNotNone (_ldap .MOD_DELETE )
137
+ self .assertIsNotNone (_ldap .MOD_REPLACE )
138
+ self .assertIsNotNone (_ldap .MOD_INCREMENT )
139
+ self .assertIsNotNone (_ldap .MOD_BVALUES )
146
140
147
141
# for result4()
148
- self .assertNotNone (_ldap .MSG_ONE )
149
- self .assertNotNone (_ldap .MSG_ALL )
150
- self .assertNotNone (_ldap .MSG_RECEIVED )
142
+ self .assertIsNotNone (_ldap .MSG_ONE )
143
+ self .assertIsNotNone (_ldap .MSG_ALL )
144
+ self .assertIsNotNone (_ldap .MSG_RECEIVED )
151
145
152
146
# for OPT_DEFEF
153
- self .assertNotNone (_ldap .DEREF_NEVER )
154
- self .assertNotNone (_ldap .DEREF_SEARCHING )
155
- self .assertNotNone (_ldap .DEREF_FINDING )
156
- self .assertNotNone (_ldap .DEREF_ALWAYS )
147
+ self .assertIsNotNone (_ldap .DEREF_NEVER )
148
+ self .assertIsNotNone (_ldap .DEREF_SEARCHING )
149
+ self .assertIsNotNone (_ldap .DEREF_FINDING )
150
+ self .assertIsNotNone (_ldap .DEREF_ALWAYS )
157
151
158
152
# for OPT_SIZELIMIT, OPT_TIMELIMIT
159
- self .assertNotNone (_ldap .NO_LIMIT )
153
+ self .assertIsNotNone (_ldap .NO_LIMIT )
160
154
161
155
# standard options
162
- self .assertNotNone (_ldap .OPT_API_INFO )
163
- self .assertNotNone (_ldap .OPT_DEREF )
164
- self .assertNotNone (_ldap .OPT_SIZELIMIT )
165
- self .assertNotNone (_ldap .OPT_TIMELIMIT )
166
- self .assertNotNone (_ldap .OPT_REFERRALS )
167
- self .assertNotNone (_ldap .OPT_RESTART )
168
- self .assertNotNone (_ldap .OPT_PROTOCOL_VERSION )
169
- self .assertNotNone (_ldap .OPT_SERVER_CONTROLS )
170
- self .assertNotNone (_ldap .OPT_CLIENT_CONTROLS )
171
- self .assertNotNone (_ldap .OPT_API_FEATURE_INFO )
172
- self .assertNotNone (_ldap .OPT_HOST_NAME )
173
- self .assertNotNone (_ldap .OPT_ERROR_NUMBER ) # = OPT_RESULT_CODE
174
- self .assertNotNone (_ldap .OPT_ERROR_STRING ) # = OPT_DIAGNOSITIC_MESSAGE
175
- self .assertNotNone (_ldap .OPT_MATCHED_DN )
156
+ self .assertIsNotNone (_ldap .OPT_API_INFO )
157
+ self .assertIsNotNone (_ldap .OPT_DEREF )
158
+ self .assertIsNotNone (_ldap .OPT_SIZELIMIT )
159
+ self .assertIsNotNone (_ldap .OPT_TIMELIMIT )
160
+ self .assertIsNotNone (_ldap .OPT_REFERRALS )
161
+ self .assertIsNotNone (_ldap .OPT_RESTART )
162
+ self .assertIsNotNone (_ldap .OPT_PROTOCOL_VERSION )
163
+ self .assertIsNotNone (_ldap .OPT_SERVER_CONTROLS )
164
+ self .assertIsNotNone (_ldap .OPT_CLIENT_CONTROLS )
165
+ self .assertIsNotNone (_ldap .OPT_API_FEATURE_INFO )
166
+ self .assertIsNotNone (_ldap .OPT_HOST_NAME )
167
+ self .assertIsNotNone (_ldap .OPT_ERROR_NUMBER ) # = OPT_RESULT_CODE
168
+ self .assertIsNotNone (_ldap .OPT_ERROR_STRING ) # = OPT_DIAGNOSITIC_MESSAGE
169
+ self .assertIsNotNone (_ldap .OPT_MATCHED_DN )
176
170
177
171
# OpenLDAP specific
178
- self .assertNotNone (_ldap .OPT_DEBUG_LEVEL )
179
- self .assertNotNone (_ldap .OPT_TIMEOUT )
180
- self .assertNotNone (_ldap .OPT_REFHOPLIMIT )
181
- self .assertNotNone (_ldap .OPT_NETWORK_TIMEOUT )
182
- self .assertNotNone (_ldap .OPT_URI )
183
- #self.assertNotNone (_ldap.OPT_REFERRAL_URLS)
184
- #self.assertNotNone (_ldap.OPT_SOCKBUF)
185
- #self.assertNotNone (_ldap.OPT_DEFBASE)
186
- #self.assertNotNone (_ldap.OPT_CONNECT_ASYNC)
172
+ self .assertIsNotNone (_ldap .OPT_DEBUG_LEVEL )
173
+ self .assertIsNotNone (_ldap .OPT_TIMEOUT )
174
+ self .assertIsNotNone (_ldap .OPT_REFHOPLIMIT )
175
+ self .assertIsNotNone (_ldap .OPT_NETWORK_TIMEOUT )
176
+ self .assertIsNotNone (_ldap .OPT_URI )
177
+ #self.assertIsNotNone (_ldap.OPT_REFERRAL_URLS)
178
+ #self.assertIsNotNone (_ldap.OPT_SOCKBUF)
179
+ #self.assertIsNotNone (_ldap.OPT_DEFBASE)
180
+ #self.assertIsNotNone (_ldap.OPT_CONNECT_ASYNC)
187
181
188
182
# str2dn()
189
- self .assertNotNone (_ldap .DN_FORMAT_LDAP )
190
- self .assertNotNone (_ldap .DN_FORMAT_LDAPV3 )
191
- self .assertNotNone (_ldap .DN_FORMAT_LDAPV2 )
192
- self .assertNotNone (_ldap .DN_FORMAT_DCE )
193
- self .assertNotNone (_ldap .DN_FORMAT_UFN )
194
- self .assertNotNone (_ldap .DN_FORMAT_AD_CANONICAL )
195
- self .assertNotNone (_ldap .DN_FORMAT_MASK )
196
- self .assertNotNone (_ldap .DN_PRETTY )
197
- self .assertNotNone (_ldap .DN_SKIP )
198
- self .assertNotNone (_ldap .DN_P_NOLEADTRAILSPACES )
199
- self .assertNotNone (_ldap .DN_P_NOSPACEAFTERRDN )
200
- self .assertNotNone (_ldap .DN_PEDANTIC )
201
- self .assertNotNone (_ldap .AVA_NULL )
202
- self .assertNotNone (_ldap .AVA_STRING )
203
- self .assertNotNone (_ldap .AVA_BINARY )
204
- self .assertNotNone (_ldap .AVA_NONPRINTABLE )
183
+ self .assertIsNotNone (_ldap .DN_FORMAT_LDAP )
184
+ self .assertIsNotNone (_ldap .DN_FORMAT_LDAPV3 )
185
+ self .assertIsNotNone (_ldap .DN_FORMAT_LDAPV2 )
186
+ self .assertIsNotNone (_ldap .DN_FORMAT_DCE )
187
+ self .assertIsNotNone (_ldap .DN_FORMAT_UFN )
188
+ self .assertIsNotNone (_ldap .DN_FORMAT_AD_CANONICAL )
189
+ self .assertIsNotNone (_ldap .DN_FORMAT_MASK )
190
+ self .assertIsNotNone (_ldap .DN_PRETTY )
191
+ self .assertIsNotNone (_ldap .DN_SKIP )
192
+ self .assertIsNotNone (_ldap .DN_P_NOLEADTRAILSPACES )
193
+ self .assertIsNotNone (_ldap .DN_P_NOSPACEAFTERRDN )
194
+ self .assertIsNotNone (_ldap .DN_PEDANTIC )
195
+ self .assertIsNotNone (_ldap .AVA_NULL )
196
+ self .assertIsNotNone (_ldap .AVA_STRING )
197
+ self .assertIsNotNone (_ldap .AVA_BINARY )
198
+ self .assertIsNotNone (_ldap .AVA_NONPRINTABLE )
205
199
206
200
# these two constants are pointless? XXX
207
201
self .assertEqual (_ldap .OPT_ON , 1 )
208
202
self .assertEqual (_ldap .OPT_OFF , 0 )
209
203
210
204
# these constants useless after ldap_url_parse() was dropped XXX
211
- self .assertNotNone (_ldap .URL_ERR_BADSCOPE )
212
- self .assertNotNone (_ldap .URL_ERR_MEM )
205
+ self .assertIsNotNone (_ldap .URL_ERR_BADSCOPE )
206
+ self .assertIsNotNone (_ldap .URL_ERR_MEM )
213
207
214
208
def test_test_flags (self ):
215
209
# test flag, see slapdtest and tox.ini
@@ -263,7 +257,7 @@ def test_anon_rootdse_search(self):
263
257
def test_unbind (self ):
264
258
l = self ._open_conn ()
265
259
m = l .unbind_ext ()
266
- self .assertNone (m )
260
+ self .assertIsNone (m )
267
261
# Second attempt to unbind should yield an exception
268
262
try :
269
263
l .unbind_ext ()
@@ -301,7 +295,7 @@ def test_abandon(self):
301
295
l = self ._open_conn ()
302
296
m = l .search_ext (self .server .suffix , _ldap .SCOPE_SUBTREE , '(objectClass=*)' )
303
297
ret = l .abandon_ext (m )
304
- self .assertNone (ret )
298
+ self .assertIsNone (ret )
305
299
try :
306
300
r = l .result4 (m , _ldap .MSG_ALL , 0.3 ) # (timeout /could/ be longer)
307
301
except _ldap .TIMEOUT as e :
0 commit comments