From: Andreas Schneider Date: Mon, 7 Mar 2022 10:22:29 +0000 (+0100) Subject: python:tests: Fix type error in raw_testcase.py X-Git-Tag: tevent-0.12.0~437 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18dbdf6aace6e37f294781fe7e379da87558992a;p=thirdparty%2Fsamba.git python:tests: Fix type error in raw_testcase.py This fixes a lot of tests with Python 3.8. Stacktrace example: File "python/samba/tests/krb5/as_req_tests.py", line 249, in test_as_req_enc_timestamp_rc4_dummy self._run_as_req_enc_timestamp( File "python/samba/tests/krb5/as_req_tests.py", line 129, in _run_as_req_enc_timestamp as_rep, kdc_exchange_dict = self._test_as_exchange( File "python/samba/tests/krb5/raw_testcase.py", line 3982, in _test_as_exchange rep = self._generic_kdc_exchange(kdc_exchange_dict, File "python/samba/tests/krb5/raw_testcase.py", line 2029, in _generic_kdc_exchange return check_rep_fn(kdc_exchange_dict, callback_dict, rep) File "python/samba/tests/krb5/raw_testcase.py", line 2328, in generic_check_kdc_rep self.check_reply_padata(kdc_exchange_dict, File "python/samba/tests/krb5/raw_testcase.py", line 2998, in check_reply_padata got_patypes = tuple(pa['padata-type'] for pa in rep_padata) TypeError: 'NoneType' object is not iterable This adds additional checks for rep_padata. Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett Reviewed-by: Joseph Sutton --- diff --git a/python/samba/tests/krb5/raw_testcase.py b/python/samba/tests/krb5/raw_testcase.py index 584a3fe5567..69c52b25761 100644 --- a/python/samba/tests/krb5/raw_testcase.py +++ b/python/samba/tests/krb5/raw_testcase.py @@ -2995,10 +2995,14 @@ class RawKerberosTest(TestCaseInTempDir): kcrypto.Enctype.AES128}: expected_patypes += (PADATA_ETYPE_INFO2,) + if not self.strict_checking and rep_padata is None: + rep_padata = () + + self.assertIsNotNone(rep_padata) got_patypes = tuple(pa['padata-type'] for pa in rep_padata) self.assertSequenceElementsEqual(expected_patypes, got_patypes) - if not expected_patypes: + if len(expected_patypes) == 0: return None pa_dict = self.get_pa_dict(rep_padata)