Skip to content

Commit 075cf2e

Browse files
committed
fix test_console test
1 parent 595aee4 commit 075cf2e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/test_app.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import cadquery as cq
1212

1313
from PyQt5.QtCore import Qt, QSettings
14-
from PyQt5.QtWidgets import QFileDialog, QMessageBox
14+
from PyQt5.QtWidgets import QApplication, QFileDialog, QMessageBox
1515

1616
from cq_editor.__main__ import MainWindow
1717
from cq_editor.widgets.editor import Editor
@@ -746,10 +746,15 @@ def test_console(main):
746746
console.execute_command('a.append(1)')
747747
assert(len(a) == 1)
748748

749+
# execute_command() creates a new prompt to be shown the next time messages are processed
750+
QApplication.processEvents()
751+
749752
# test print_text
750-
pos_orig = console._prompt_pos
751-
console.print_text('a')
752-
assert(console._prompt_pos == pos_orig + len('a'))
753+
print('printing text')
754+
text_before = console._control.document().toPlainText()
755+
console.print_text('foo')
756+
text_after = console._control.document().toPlainText()
757+
assert text_after == text_before + 'foo'
753758

754759
def test_viewer(main):
755760

0 commit comments

Comments
 (0)