Test how `DoubleValidatorRelaxed` operates with `QLineEdit`, which is expected to emit the signal `editingFinished()` only when the validator returns `Acceptable`. The typed string is supposed to be displayed (returned by `text()` method).
(qtbot, text, range, valid)
| 171 | ]) |
| 172 | # fmt: on |
| 173 | def test_DoubleValidatorRelaxed_2(qtbot, text, range, valid): |
| 174 | """ |
| 175 | Test how `DoubleValidatorRelaxed` operates with `QLineEdit`, which is expected |
| 176 | to emit the signal `editingFinished()` only when the validator returns `Acceptable`. |
| 177 | The typed string is supposed to be displayed (returned by `text()` method). |
| 178 | """ |
| 179 | le = QLineEdit() |
| 180 | validator = DoubleValidatorRelaxed() |
| 181 | le.setValidator(validator) |
| 182 | qtbot.addWidget(le) |
| 183 | le.show() |
| 184 | |
| 185 | if range is not None: |
| 186 | validator.setRange(range[0], range[1], decimals=10) |
| 187 | |
| 188 | def fn(): |
| 189 | enter_text_via_keyboard(qtbot, le, text) |
| 190 | |
| 191 | signal = le.editingFinished |
| 192 | if valid: |
| 193 | # 'editingFinished()' should be emitted |
| 194 | with qtbot.waitSignal(signal, timeout=100): |
| 195 | fn() |
| 196 | else: |
| 197 | # 'editingFinished()' should not be emitted |
| 198 | with qtbot.assertNotEmitted(signal, wait=100): |
| 199 | fn() |
| 200 | |
| 201 | # We verify that the text can be entered via keyboard is still displayed |
| 202 | assert le.text() == text, "Entered and displayed text does not match" |
| 203 | |
| 204 | |
| 205 | # ============================================================== |
nothing calls this directly
no test coverage detected