Skip to content

Commit 1ddc080

Browse files
committed
Fix minor python3 issues in config tests
* sys.version is not suitable for comparisons, and strings and tuples don't compare like that in python3 anyway. Fixing to use sys.version_info. * More views that need to be casted to lists.
1 parent 38c250d commit 1ddc080

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/test_31_config.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ def test_1():
180180
assert isinstance(md, MetadataStore)
181181

182182
assert len(c._sp_idp) == 1
183-
assert c._sp_idp.keys() == ["urn:mace:example.com:saml:roland:idp"]
184-
assert c._sp_idp.values() == [{'single_sign_on_service':
185-
{
186-
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect':
187-
'http://localhost:8088/sso/'}}]
183+
assert list(c._sp_idp.keys()) == ["urn:mace:example.com:saml:roland:idp"]
184+
assert list(c._sp_idp.values()) == [{'single_sign_on_service':
185+
{
186+
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect':
187+
'http://localhost:8088/sso/'}}]
188188

189189
assert c.only_use_keys_in_metadata
190190

@@ -202,8 +202,8 @@ def test_2():
202202
assert c._sp_required_attributes
203203

204204
assert len(c._sp_idp) == 1
205-
assert c._sp_idp.keys() == [""]
206-
assert c._sp_idp.values() == [
205+
assert list(c._sp_idp.keys()) == [""]
206+
assert list(c._sp_idp.values()) == [
207207
"https://example.com/saml2/idp/SSOService.php"]
208208
assert c.only_use_keys_in_metadata is True
209209

@@ -263,7 +263,7 @@ def test_wayf():
263263
c.context = "sp"
264264

265265
idps = c.metadata.with_descriptor("idpsso")
266-
ent = idps.values()[0]
266+
ent = list(idps.values())[0]
267267
assert name(ent) == 'Example Co.'
268268
assert name(ent, "se") == 'Exempel AB'
269269

@@ -305,7 +305,8 @@ def test_conf_syslog():
305305
print(handler.__dict__)
306306
assert handler.facility == "local3"
307307
assert handler.address == ('localhost', 514)
308-
if sys.version >= (2, 7):
308+
if ((sys.version_info.major == 2 and sys.version_info.minor >= 7) or
309+
sys.version_info.major > 2):
309310
assert handler.socktype == 2
310311
else:
311312
pass

0 commit comments

Comments
 (0)