From 800ba9645dc180f8be4ac68e231cd7b7c6e42716 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Tue, 18 Jan 2022 00:43:08 +0100 Subject: [PATCH] Fix tests on Python3.10 Both test_property_protection_with_missing_operation and test_property_protection_with_misspelt_operation rely on a bug in Python 3.9: the "]" character in a section name is not read, so section '^[0-9]' is read as '^[0-9'. This causes _compile_rule to fail and raise the exception the tests are expecting. In Python 3.10, this bug has been fixed and the exception is no longer raised. Instead, CONFIG.get() raises a NoOptionError in _load_rules, which is not caught. Closes-Bug: #1954321 Change-Id: Ibce11ac002dc900299d478ea875797dd1f8df17e --- glance/common/property_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glance/common/property_utils.py b/glance/common/property_utils.py index c9befa88dd..473440bb8a 100644 --- a/glance/common/property_utils.py +++ b/glance/common/property_utils.py @@ -134,7 +134,10 @@ class PropertyRules(object): compiled_rule = self._compile_rule(property_exp) for operation in operations: - permissions = CONFIG.get(property_exp, operation) + try: + permissions = CONFIG.get(property_exp, operation) + except configparser.NoOptionError: + raise InvalidPropProtectConf() if permissions: if self.prop_prot_rule_format == 'policies': if ',' in permissions: