1313from qtpy import QtWidgets as QW
1414
1515from cdl .env import execenv
16+ from cdl .obj import ImageObj , SignalObj
1617from cdl .tests .data import get_test_fnames
1718from cdl .widgets .textimport import TextImportWizard
1819
@@ -27,20 +28,40 @@ def file_to_clipboard(filename: str) -> None:
2728def test_import_wizard ():
2829 """Test the import wizard"""
2930 with qt_app_context ():
30- for destination , fname in (
31- ("image" , "fiber.txt" ),
32- ("signal" , "paracetamol.txt" ),
31+ for destination , fname , otype in (
32+ ("image" , "fiber.txt" , ImageObj ),
33+ ("signal" , "paracetamol.txt" , SignalObj ),
3334 ):
35+ path = get_test_fnames (fname )[0 ]
3436 if not execenv .unattended :
3537 # Do not test clipboard in unattended mode, would fail:
3638 # - Windows: OleSetClipboard: Failed to set mime data (text/plain)
3739 # on clipboard: COM error 0xffffffff800401d0
3840 # - Linux: QXcbClipboard: Unable to receive an event from the clipboard
3941 # manager in a reasonable time
40- path = get_test_fnames (fname )[0 ]
4142 file_to_clipboard (path )
4243 wizard = TextImportWizard (destination = destination )
43- if exec_dialog (wizard ):
44+ if execenv .unattended :
45+ wizard .show ()
46+ srcpge = wizard .source_page
47+ srcpge .source_widget .file_edit .setText (path )
48+ srcpge .source_widget .file_edit .editingFinished .emit ()
49+ wizard .go_to_next_page ()
50+ datapge = wizard .data_page
51+ if fname == "fiber.txt" :
52+ datapge .param .delimiter_choice = " "
53+ else :
54+ datapge .param .skip_rows = 10
55+ datapge .param_widget .get ()
56+ datapge .update_preview ()
57+ wizard .go_to_next_page ()
58+ wizard .go_to_previous_page () # For test purpose only
59+ wizard .go_to_next_page ()
60+ wizard .go_to_next_page ()
61+ wizard .accept ()
62+ assert len (wizard .get_objs ()) == 1
63+ assert isinstance (wizard .get_objs ()[0 ], otype )
64+ elif exec_dialog (wizard ):
4465 for obj in wizard .get_objs ():
4566 execenv .print (obj )
4667
0 commit comments