Esempio n. 1
0
def test_assign_only_orphan(scratch):
    w1 = Widget()
    w2 = Widget()

    Application().assign_orphan_widgets()

    assert "/" in Page._dict
    assert Page._dict["/"].widgets[0] is w1
    assert Page._dict["/"].widgets[1] is w2
Esempio n. 2
0
def test_assign_orphan_already_home(scratch):
    Page()
    Widget()
    Widget()

    Application().assign_orphan_widgets()

    assert "/" in Page._dict
    assert len(Page._dict["/"].widgets) == 2
Esempio n. 3
0
def test_context_manager_page(scratch):
    Widget()
    p = Page()
    with p:
        w1 = Widget()
        w2 = Widget()
    Widget()

    assert len(p.widgets) == 2
    assert w1 in p.widgets
    assert w2 in p.widgets
Esempio n. 4
0
def test_assign_orphan(scratch):
    w1 = Widget()
    w2 = Widget()
    w3 = Widget()
    p = Page("/test")
    p.add(w2)

    Application().assign_orphan_widgets()

    assert "/" in Page._dict and "/test" in Page._dict
    assert Page._dict["/"].widgets[0] is w1
    assert Page._dict["/test"].widgets[0] is w2
    assert Page._dict["/"].widgets[1] is w3
Esempio n. 5
0
def test_widget_id(scratch):
    w1 = Widget()
    w2 = Input()
    w3 = Widget()
    assert w1.id != w2.id != w3.id
Esempio n. 6
0
def test_widget_cls_error():
    with pytest.raises(ValueError):
        Widget(cls=1)
Esempio n. 7
0
def test_widget_cls(kwargs, cls):
    w1 = Widget(**kwargs)
    assert set(w1.cls) == set(cls)
Esempio n. 8
0
def test_widget_declared(scratch):
    w1 = Widget()
    w2 = Input()
    w3 = Widget()
    assert Widget._declared == [w1, w2, w3]