Fix wrong use of identity operation

Strings should not be compared with the identity operation 'is' or
'is not'.

Fixes: https://pagure.io/freeipa/issue/8057
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Christian Heimes
2019-09-03 13:55:27 +02:00
committed by Florence Blanc-Renaud
parent 8d2125f654
commit 0fc4b8c25c
5 changed files with 7 additions and 7 deletions

View File

@@ -465,4 +465,4 @@ class test_smb_service(KeytabRetrievalTest):
entry = conn.retrieve(test_smb_svc.dn, ['ipaNTHash'])
ipanthash = entry.single_value.get('ipanthash')
conn.disconnect()
assert ipanthash is not b'MagicRegen', 'LDBM backend entry corruption'
assert ipanthash != b'MagicRegen', 'LDBM backend entry corruption'

View File

@@ -187,7 +187,7 @@ class test_Gettext:
inst = self.klass('what up?', 'foo', 'bar')
assert inst.domain == 'foo'
assert inst.localedir == 'bar'
assert inst.msg is 'what up?'
assert inst.msg == 'what up?'
assert inst.args == ('what up?', 'foo', 'bar')
def test_repr(self):
@@ -349,7 +349,7 @@ class test_GettextFactory:
inst = self.klass('foo', 'bar')
g = inst('what up?')
assert type(g) is text.Gettext
assert g.msg is 'what up?'
assert g.msg == 'what up?'
assert g.domain == 'foo'
assert g.localedir == 'bar'

View File

@@ -233,7 +233,7 @@ class test_LDAPEntry:
e = self.entry
assert e.pop('cn') == self.cn1
assert 'cn' not in e
assert e.pop('cn', 'default') is 'default'
assert e.pop('cn', 'default') == 'default'
with pytest.raises(KeyError):
e.pop('cn')

View File

@@ -451,7 +451,7 @@ class TestPermission(XMLRPC_test):
) as ewe:
find = certmap_rule.make_find_command()
res = find(**{k: v for k, v in certmaprule_create_params.items()
if k is not u'dn'})
if k != u'dn'})
ewe.send(res)
def test_update(self, certmap_rule, certmap_user_permissions):

View File

@@ -227,7 +227,7 @@ class UserTracker(CertmapdataMixin, KerberosAliasMixin, Tracker):
result = command()
for key, value in updates.items():
if value is None or value is '' or value is u'':
if value is None or value == '':
del self.attrs[key]
elif key == 'rename':
new_principal = u'{0}@{1}'.format(value, self.api.env.realm)
@@ -241,7 +241,7 @@ class UserTracker(CertmapdataMixin, KerberosAliasMixin, Tracker):
else:
self.attrs[key] = [value]
for key, value in expected_updates.items():
if value is None or value is '' or value is u'':
if value is None or value == '':
del self.attrs[key]
else:
self.attrs[key] = value