Skip to content

Commit 2a431c6

Browse files
committed
Test for attr membership on a frequently-used attr
While this can still fail, less likely to fail than querying on the last-seen attr. In particular, some mechanisms will not respond to an inquiry for that attr despite claiming to have it. Signed-off-by: Alexander Scheel <[email protected]>
1 parent f84f090 commit 2a431c6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gssapi/tests/test_raw.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def test_rfc5587(self):
660660
# Since mechs is of type set and thus not indexable, these
661661
# are used to track the last visited mech for testing
662662
# purposes, and saves a call to inquire_attrs_for_mech().
663-
last_attr = None
663+
attrs_dict = {}
664664
last_mech = None
665665

666666
for mech in mechs:
@@ -691,7 +691,9 @@ def test_rfc5587(self):
691691
display_out.short_desc.should_be_a(bytes)
692692
display_out.long_desc.should_be_a(bytes)
693693

694-
last_attr = mech_attr
694+
if mech_attr not in attrs_dict:
695+
attrs_dict[mech_attr] = 0
696+
attrs_dict[mech_attr] += 1
695697

696698
for mech_attr in known_mech_attrs:
697699
mech_attr.shouldnt_be_none()
@@ -705,7 +707,12 @@ def test_rfc5587(self):
705707
display_out.short_desc.should_be_a(bytes)
706708
display_out.long_desc.should_be_a(bytes)
707709

708-
attrs = set([last_attr])
710+
if mech_attr not in attrs_dict:
711+
attrs_dict[mech_attr] = 0
712+
attrs_dict[mech_attr] += 1
713+
714+
max_attr = max(attrs_dict, key=attrs_dict.get)
715+
attrs = set([max_attr])
709716

710717
mechs = gb.indicate_mechs_by_attrs(attrs, None, None)
711718
mechs.shouldnt_be_empty()

0 commit comments

Comments
 (0)