示例#1
0
 def test_set_new_document(self):
     old_doc = get_document()
     doc = get_new_document()
     self.assertIsNot(doc, old_doc)
     set_document(doc)
     new_doc = get_document()
     self.assertIsNot(doc, old_doc)
     self.assertIs(doc, new_doc)
示例#2
0
 def test_set_new_document(self):
     old_doc = get_document()
     doc = get_new_document()
     self.assertIsNot(doc, old_doc)
     set_document(doc)
     new_doc = get_document()
     self.assertIsNot(doc, old_doc)
     self.assertIs(doc, new_doc)
示例#3
0
def reset() -> None:
    """Reset all wdom objects.

    This function clear all connections, elements, and resistered custom
    elements. This function also makes new document/application and set them.
    """
    from wdom.document import get_new_document, set_document
    from wdom.element import Element
    from wdom.server import _tornado
    from wdom.window import customElements

    set_document(get_new_document())
    _tornado.connections.clear()
    _tornado.set_application(_tornado.Application())
    Element._elements_with_id.clear()
    Element._element_buffer.clear()
    customElements.reset()
示例#4
0
文件: testing.py 项目: miyakogi/wdom
def reset():
    """Reset all wdom objects.

    This function clear all connections, elements, and resistered custom
    elements. This function also makes new document/application and set them.
    """
    from wdom.document import get_new_document, set_document

    set_document(get_new_document())
    from wdom.server import _tornado

    _tornado.connections.clear()
    _tornado.set_application(_tornado.Application())
    try:
        from wdom.server import _aiohttp

        _aiohttp.connections.clear()
        _aiohttp.set_application(_aiohttp.Application())
    except ImportError:
        pass
    Element._elements_with_id.clear()
    Element._elements.clear()
    customElements.clear()
示例#5
0
 def tearDown(self):
     stop_server(self.server)
     set_document(get_new_document())
     sync(self.page.goto('about:blank'))
     time.sleep(0.1)