Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_register_validation():
page = Page()
with pytest.raises(AssertionError):
page.register(view.Panel)
with pytest.raises(AssertionError):
page.register({})
def new_panel(self, header=None, active=False, **kwargs):
"""
Add a panel child.
:param header: If supplied, should be the text to display as the panel header.
Otherwise, the returned panel element will expose a ``header`` field.
This field should be used to create an element hierarchy (similar to ``Page``) that will be
passed as a ``ReactNode`` to the underlying ant design react ``Panel`` component.
:param active: Should this panel be collapsed or expanded by default. (default: False)
:return: The created panel element.
"""
result = self._new_child(Panel, header=header, **kwargs)
if active:
self.props['defaultActiveKey'].append(result.id)
self.update_props(self.props)
return result
def _new_child(self, cls, **kwargs):
assert issubclass(cls, Panel)
return super(Collapse, self)._new_child(cls, **kwargs)