From 3c8adced2ce8a74b585c7b4667071621c34b6e0d Mon Sep 17 00:00:00 2001 From: Christodoulos Tsoulloftas Date: Sun, 16 Jul 2023 12:40:18 +0300 Subject: [PATCH] Adding tests --- .../codegen/handlers/test_validate_attributes_overrides.py | 7 +++++++ xsdata/codegen/handlers/validate_attributes_overrides.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/codegen/handlers/test_validate_attributes_overrides.py b/tests/codegen/handlers/test_validate_attributes_overrides.py index 78da4350..af25d29d 100644 --- a/tests/codegen/handlers/test_validate_attributes_overrides.py +++ b/tests/codegen/handlers/test_validate_attributes_overrides.py @@ -102,12 +102,19 @@ def test_validate_override(self): attr_b.fixed = attr_a.fixed attr_a.restrictions.tokens = not attr_b.restrictions.tokens attr_a.restrictions.nillable = not attr_b.restrictions.nillable + attr_a.restrictions.min_occurs = 0 + attr_b.restrictions.min_occurs = 1 + attr_a.restrictions.max_occurs = 0 + attr_b.restrictions.max_occurs = 1 + self.processor.validate_override(target, attr_a, attr_b) self.assertEqual(1, len(target.attrs)) # Restrictions are compatible again attr_a.restrictions.tokens = attr_b.restrictions.tokens attr_a.restrictions.nillable = attr_b.restrictions.nillable + attr_a.restrictions.min_occurs = attr_b.restrictions.min_occurs = 1 + attr_a.restrictions.max_occurs = attr_b.restrictions.max_occurs = 1 self.processor.validate_override(target, attr_a, attr_b) self.assertEqual(0, len(target.attrs)) diff --git a/xsdata/codegen/handlers/validate_attributes_overrides.py b/xsdata/codegen/handlers/validate_attributes_overrides.py index ae73cc1b..9e93bfc9 100644 --- a/xsdata/codegen/handlers/validate_attributes_overrides.py +++ b/xsdata/codegen/handlers/validate_attributes_overrides.py @@ -60,8 +60,8 @@ def validate_override(cls, target: Class, attr: Attr, source_attr: Attr): and bool_eq(attr.mixed, source_attr.mixed) and bool_eq(attr.restrictions.tokens, source_attr.restrictions.tokens) and bool_eq(attr.restrictions.nillable, source_attr.restrictions.nillable) - and bool_eq(attr.restrictions.is_optional, source_attr.restrictions.is_optional) - and bool_eq(attr.restrictions.is_prohibited, source_attr.restrictions.is_prohibited) + and bool_eq(attr.is_prohibited, source_attr.is_prohibited) + and bool_eq(attr.is_optional, source_attr.is_optional) ): cls.remove_attribute(target, attr)