@pytest.mark.parametrize('elidemode, check', [(Qt.ElideRight, (lambda s: (s.endswith('\xe2\x80\xa6') or s.endswith('...')))), (Qt.ElideLeft, (lambda s: (s.startswith('\xe2\x80\xa6') or s.startswith('...')))), (Qt.ElideMiddle, (lambda s: (('\xe2\x80\xa6' in s) or ('...' in s)))), (Qt.ElideNone, (lambda s: (('\xe2\x80\xa6' not in s) and ('...' not in s))))])
def test_elided_text(fake_statusbar, qtbot, elidemode, check):
 label = TextBase(elidemode=elidemode)
 qtbot.add_widget(label)
 fake_statusbar.hbox.addWidget(label)
 long_string = ('Hello world! ' * 100)
 label.setText(long_string)
 label.show()
 assert check(label._elided_text)

@ pytest . mark . parametrize ( 'elidemode, check' , [ ( Qt . ElideRight , ( lambda s : ( s . endswith ( '\xe2\x80\xa6' ) or s . endswith ( '...' ) ) ) ) , ( Qt . ElideLeft , ( lambda s : ( s . startswith ( '\xe2\x80\xa6' ) or s . startswith ( '...' ) ) ) ) , ( Qt . ElideMiddle , ( lambda s : ( ( '\xe2\x80\xa6' in s ) or ( '...' in s ) ) ) ) , ( Qt . ElideNone , ( lambda s : ( ( '\xe2\x80\xa6' not in s ) and ( '...' not in s ) ) ) ) ] ) def test_elided_text ( fake_statusbar , qtbot , elidemode , check ) : label = TextBase ( elidemode = elidemode ) qtbot . add_widget ( label ) fake_statusbar . hbox . addWidget ( label ) long_string = ( 'Hello world! ' * 100 ) label . setText ( long_string ) label . show ( ) assert check ( label . _elided_text )
ensure that a widget too small to hold the entire label text will elide .