From 1933e604fb0822bc08caa4aec499be949f731d3b Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: May 30 2016 14:44:08 +0000 Subject: test_ipaserver.test_ldap: Adjust tests to Python 3's KeyView In Python 3, the keys() method of mappings returns a KeyView object that reflects the mapping's state. In LDAPEntry, this means that the collection returned by keys() is case-insensitive and supports aliases. Part of the fix for: https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Martin Basti --- diff --git a/ipatests/test_ipaserver/test_ldap.py b/ipatests/test_ipaserver/test_ldap.py index 54c86c8..fe1ba1d 100644 --- a/ipatests/test_ipaserver/test_ldap.py +++ b/ipatests/test_ipaserver/test_ldap.py @@ -184,9 +184,15 @@ class test_LDAPEntry(object): assert u'cn' in e assert u'cn' in e.keys() assert 'CN' in e - assert 'CN' not in e.keys() + if six.PY2: + assert 'CN' not in e.keys() + else: + assert 'CN' in e.keys() assert 'commonName' in e - assert 'commonName' not in e.keys() + if six.PY2: + assert 'commonName' not in e.keys() + else: + assert 'commonName' in e.keys() assert e['CN'] is self.cn1 assert e['CN'] is e[u'cn'] @@ -199,9 +205,15 @@ class test_LDAPEntry(object): assert u'cn' in e assert u'cn' in e.keys() assert 'CN' in e - assert 'CN' not in e.keys() + if six.PY2: + assert 'CN' not in e.keys() + else: + assert 'CN' in e.keys() assert 'commonName' in e - assert 'commonName' not in e.keys() + if six.PY2: + assert 'commonName' not in e.keys() + else: + assert 'commonName' in e.keys() assert e['CN'] is self.cn2 assert e['CN'] is e[u'cn']