예제 #1
0
def test_dock():
    name = pg.asUnicode("évènts_zàhéér")
    dock = da.Dock(name=name)
    # make sure unicode names work correctly
    assert dock.name() == name
    # no surprises in return type.
    assert type(dock.name()) == type(name)
예제 #2
0
def test_dock():
    name = pg.asUnicode("évènts_zàhéér")
    dock = da.Dock(name=name)
    # make sure unicode names work correctly
    assert dock.name() == name
    # no surprises in return type.
    assert type(dock.name()) == type(name)
예제 #3
0
def test_spinbox_formatting():
    sb = pg.SpinBox()
    assert sb.opts['decimals'] == 6
    assert sb.opts['int'] is False

    # table  of test conditions:
    # value, text, options
    conds = [
        (0, '0', dict(suffix='', siPrefix=False, dec=False, int=False)),
        (100, '100', dict()),
        (1000000, '1e+06', dict()),
        (1000, '1e+03', dict(decimals=2)),
        (1000000, '1e+06', dict(int=True, decimals=6)),
        (12345678955, '12345678955', dict(int=True, decimals=100)),
        (1.45e-9, '1.45e-09 A',
         dict(int=False, decimals=6, suffix='A', siPrefix=False)),
        (1.45e-9, '1.45 nA',
         dict(int=False, decimals=6, suffix='A', siPrefix=True)),
        (1.45, '1.45 PSI',
         dict(int=False, decimals=6, suffix='PSI', siPrefix=True)),
        (1.45e-3, '1.45 mPSI',
         dict(int=False, decimals=6, suffix='PSI', siPrefix=True)),
        (-2500.3427, '$-2500.34', dict(int=False, format='${value:0.02f}')),
    ]

    for (value, text, opts) in conds:
        sb.setOpts(**opts)
        sb.setValue(value)
        assert sb.value() == value
        assert pg.asUnicode(sb.text()) == text

        # test setting value
        if not opts.get('int', False):
            suf = sb.opts['suffix']
            sb.lineEdit().setText('0.1' + suf)
            sb.editingFinishedEvent()
            assert sb.value() == 0.1
            if suf != '':
                sb.lineEdit().setText('0.1 m' + suf)
                sb.editingFinishedEvent()
                assert sb.value() == 0.1e-3
예제 #4
0
def test_spinbox_formatting():
    sb = pg.SpinBox()
    assert sb.opts['decimals'] == 6
    assert sb.opts['int'] is False
    
    # table  of test conditions:
    # value, text, options
    conds = [
        (0, '0', dict(suffix='', siPrefix=False, dec=False, int=False)),
        (100, '100', dict()),
        (1000000, '1e+06', dict()),
        (1000, '1e+03', dict(decimals=2)),
        (1000000, '1e+06', dict(int=True, decimals=6)),
        (12345678955, '12345678955', dict(int=True, decimals=100)),
        (1.45e-9, '1.45e-09 A', dict(int=False, decimals=6, suffix='A', siPrefix=False)),
        (1.45e-9, '1.45 nA', dict(int=False, decimals=6, suffix='A', siPrefix=True)),
        (1.45, '1.45 PSI', dict(int=False, decimals=6, suffix='PSI', siPrefix=True)),
        (1.45e-3, '1.45 mPSI', dict(int=False, decimals=6, suffix='PSI', siPrefix=True)),
        (-2500.3427, '$-2500.34', dict(int=False, format='${value:0.02f}')),
    ]
    
    for (value, text, opts) in conds:
        sb.setOpts(**opts)
        sb.setValue(value)
        assert sb.value() == value
        assert pg.asUnicode(sb.text()) == text

        # test setting value
        if not opts.get('int', False):
            suf = sb.opts['suffix']
            sb.lineEdit().setText('0.1' + suf)
            sb.editingFinishedEvent()
            assert sb.value() == 0.1
            if suf != '':
                sb.lineEdit().setText('0.1 m' + suf)
                sb.editingFinishedEvent()
                assert sb.value() == 0.1e-3
예제 #5
0
def test_SpinBox_formatting(value, expected_text, opts):
    sb = pg.SpinBox(**opts)
    sb.setValue(value)

    assert sb.value() == value
    assert pg.asUnicode(sb.text()) == expected_text
예제 #6
0
 def fmt(item):
     if isinstance(item.value, float):
         return "%d %f" % (item.index, item.value)
     else:
         return pg.asUnicode(item.value)
예제 #7
0
 def fmt(item):
     if isinstance(item.value, float):
         return "%d %f" % (item.index, item.value)
     else:
         return pg.asUnicode(item.value)