Skip to content

Commit

Permalink
Fix for issue #300
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed May 27, 2022
1 parent 73b0e78 commit 5ff0a48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/test_dataobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ def test_element_binding(self):
self.assertTrue(issubclass(xsd_element.binding, DataElement))
self.assertIsInstance(xsd_element.binding, DataBindingMeta)
self.assertIs(binding_class, xsd_element.binding)

# regression tests for issue 300
self.assertIs(binding_class, xsd_element.get_binding())
self.assertIsNot(binding_class, xsd_element.get_binding(replace_existing=True))
finally:
xsd_element.binding = None

Expand Down
2 changes: 1 addition & 1 deletion xmlschema/validators/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def get_binding(self, *bases: Type[Any], replace_existing: bool = False, **attrs
:param replace_existing: provide `True` to replace an existing binding class.
:param attrs: attribute and method definitions for the binding class body.
"""
if self.binding is None or not replace_existing:
if self.binding is None or replace_existing:
if not bases:
bases = (dataobjects.DataElement,)
attrs['xsd_element'] = self
Expand Down

0 comments on commit 5ff0a48

Please sign in to comment.