示例#1
0
def test_empty_func():
    def noop(doc):
        pass
    handler = FunctionHandler(noop)
    doc = Document()
    handler.modify_document(doc)
    if handler.failed:
        raise RuntimeError(handler.error)
    assert not doc.roots
示例#2
0
def test_empty_func():
    def noop(doc):
        pass

    handler = FunctionHandler(noop)
    doc = Document()
    handler.modify_document(doc)
    if handler.failed:
        raise RuntimeError(handler.error)
    assert not doc.roots
示例#3
0
def test_safe_to_fork():
    def noop(doc):
        pass
    handler = FunctionHandler(noop)
    doc = Document()
    assert handler.safe_to_fork
    handler.modify_document(doc)
    if handler.failed:
        raise RuntimeError(handler.error)
    assert not handler.safe_to_fork
示例#4
0
def test_func_adds_roots():
    def add_roots(doc):
        doc.add_root(AnotherModelInTestFunction())
        doc.add_root(SomeModelInTestFunction())
    handler = FunctionHandler(add_roots)
    doc = Document()
    handler.modify_document(doc)
    if handler.failed:
        raise RuntimeError(handler.error)
    assert len(doc.roots) == 2
示例#5
0
def test_safe_to_fork():
    def noop(doc):
        pass

    handler = FunctionHandler(noop)
    doc = Document()
    assert handler.safe_to_fork
    handler.modify_document(doc)
    if handler.failed:
        raise RuntimeError(handler.error)
    assert not handler.safe_to_fork
示例#6
0
def test_func_adds_roots():
    def add_roots(doc):
        doc.add_root(AnotherModelInTestFunction())
        doc.add_root(SomeModelInTestFunction())

    handler = FunctionHandler(add_roots)
    doc = Document()
    handler.modify_document(doc)
    if handler.failed:
        raise RuntimeError(handler.error)
    assert len(doc.roots) == 2