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_is_parsable():
assert parser.is_parsable('')
assert parser.is_parsable({})
assert parser.is_parsable([])
assert not parser.is_parsable(None)
assert not parser.is_parsable(view.Element)
assert not parser.is_parsable(view.CustomElement)
def test_parse_custom_element():
class TestElement(view.CustomElement):
@classmethod
def _js(cls):
pass
page = Page()
page.register(TestElement)
result = page.new('TestElement')
assert isinstance(result, TestElement)
def _get_id_and_store(self, obj, obj_id):
obj_id = obj_id or getattr(obj, 'id', str(id(obj)))
if isinstance(obj, view.Root):
store = self.roots
elif isinstance(obj, view.Element):
store = self.elements
elif isinstance(obj, type) and issubclass(obj, view.CustomElement):
store = self.element_types
elif isinstance(obj, variables.Variable):
store = self.variables
elif callable(obj):
store = self.functions
else:
raise RuntimeError('No registry is defined for objects of type {}'.format(type(obj).__name__))
return obj_id, store