Ejemplo n.º 1
0
def test_label_case_sensitivity(qtbot, caplog, taurus_test_ds):
    """Verify that case is respected of in the label widget"""
    with check_taurus_deprecations(caplog, expected=0):
        w = TaurusValue()
        qtbot.addWidget(w)
        w.setModel("tango:{}/MIXEDcase".format(taurus_test_ds))

        def _ok():
            assert w.labelWidget().text() == "MIXEDcase"

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 2
0
def test_bug126(qtbot, caplog):
    """Verify that case is not lost when customizing a label (bug#126)"""
    with check_taurus_deprecations(caplog, expected=0):
        w = TaurusValue()
        qtbot.addWidget(w)
        w.setModel("tango:sys/tg_test/1/double_scalar")
        label = "MIXEDcase"
        w.setLabelConfig(label)

        def _ok():
            assert w.labelWidget().text() == label

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 3
0
def test_display_value(qtbot, caplog, taurus_test_ds, model, expected):
    """Check the getDisplayValue method"""
    with check_taurus_deprecations(caplog):
        w = TaurusWidget()
        qtbot.addWidget(w)
        if model.startswith("/"):
            model = "tango:{}{}".format(taurus_test_ds, model)
        with qtbot.waitSignal(w.modelChanged, timeout=3200):
            w.setModel(model)

        def _ok():
            """Check text"""
            assert w.getDisplayValue() == expected

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 4
0
def test_class_format(monkeypatch, qtbot, caplog, model, fmt, fg):
    """Check formatter API at class level"""
    monkeypatch.setattr(TaurusLabel, "FORMAT", fmt)

    with check_taurus_deprecations(caplog, expected=0):
        w = TaurusLabel()
        qtbot.addWidget(w)

        w.setModel(model)
        w.resetFormat()  # needed to avoid fuzzyness in the tests

        def _ok():
            """Check text"""
            assert w.text() == fg

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 5
0
def _chek_tauruslabel(
    qtbot,
    caplog,
    taurus_test_ds,
    model,
    fmt=None,
    fgRole=None,
    bgRole=None,
    modelIndex=None,
    depr=0,
    expected_fg=None,
    expected_bg=None,
):
    """Check the label foreground and background"""
    # TODO: these tests are not properly isolated. For example, the
    #       parameterization testing fgrole="quality" fails in PySide2
    #       if it is called after another parameterization.
    if expected_fg is None and expected_bg is None:
        raise ValueError("expected_fg or expected_bg must not be None")
    with check_taurus_deprecations(caplog, expected=depr):
        w = TaurusLabel()
        qtbot.addWidget(w)
        if model.startswith("/"):
            model = "tango:{}{}".format(taurus_test_ds, model)
        with qtbot.waitSignal(w.modelChanged, timeout=3200):
            w.setModel(model)
        if fmt is not None:
            w.setFormat(fmt)
        if modelIndex is not None:
            w.setModelIndex(modelIndex)
        if fgRole is not None:
            w.setFgRole(fgRole)
        if bgRole is not None:
            w.setBgRole(bgRole)

        def _ok():
            """Check text"""
            if expected_fg is not None:
                assert w.text() == expected_fg
            if expected_bg is not None:
                p = w.palette()
                assert p.color(p.Background).getRgb()[:3] == expected_bg

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 6
0
def test_set_models(qtbot, caplog, widgetname, depr, models):
    """
    Generic test that checks that a widget can be instantiated and given
    its setModel called sequentially.

    It can be parameterized or run with functools.partial
    """
    with check_taurus_deprecations(caplog, expected=depr):
        klass = _import_obj(widgetname)
        w = klass()
        qtbot.addWidget(w)

        for model in models:
            if not model:
                model_obj = None
            else:
                try:
                    model_obj = taurus.Object(model)
                except:  # allow non-string models (e.g. lists of models)
                    model_obj = None
            w.setModel(model)
            assert w.getModelObj() == model_obj
Ejemplo n.º 7
0
def test_taurusvalue_subwidget_texts(qtbot, caplog):
    """Checks the texts for scalar attributes"""

    model = "eval:@a=taurus.core.evaluation.test.res.mymod.MyClass()/a.foo"
    expected = ("a.foo", "123", "123", "m")
    depr = 0

    with check_taurus_deprecations(caplog, expected=depr):
        w = TaurusValue()
        qtbot.addWidget(w)
        w.setModel(model)

        def _ok():
            got = (
                str(w.labelWidget().text()),
                str(w.readWidget().text()),
                str(w.writeWidget().displayText()),
                str(w.unitsWidget().text()),
            )
            assert got == expected

        qtbot.waitUntil(_ok, timeout=3200)