Skip to content

Commit

Permalink
fixed file dialogs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerum committed Jan 21, 2025
1 parent f55b9ef commit 133ca00
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/test_use_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def handle_files(self: AddFilesDialog):
# assert sf4(M.U[M.reg_mask][0]) == sf4([-2.01259036e-38, -1.96865342e-38, -4.92921492e-38])
# 91.64216076e-38 -3.15079497e-39 3.19069614e-39

monkeypatch.setattr(QtWidgets.QFileDialog, "getSaveFileName", lambda *args: "tmp")
monkeypatch.setattr(QtWidgets.QFileDialog, "getSaveFileName", lambda *args: ("tmp",))
batch_evaluate.generate_code()

# open all the tabs
Expand All @@ -218,7 +218,7 @@ def handle_files(self: AddFilesDialog):
batch_evaluate.tab1.contrast_enhance.setValue(1)
batch_evaluate.tab1.button.clicked.emit()

monkeypatch.setattr(QtWidgets.QFileDialog, "getSaveFileName", lambda *args: "export.tif")
monkeypatch.setattr(QtWidgets.QFileDialog, "getSaveFileName", lambda *args: ("export.tif",))
batch_evaluate.tab1.button2.clicked.emit()

if use_time:
Expand Down Expand Up @@ -733,14 +733,14 @@ def test_code(monkeypatch, catch_popup_error, random_path):
from saenopy.gui.code.gui_code import MainWindowCode
coder: MainWindowCode = window.coder

monkeypatch.setattr(QtWidgets.QFileDialog, "getOpenFileName", lambda *args: "test_code.py")
monkeypatch.setattr(QtWidgets.QFileDialog, "getOpenFileName", lambda *args: ("test_code.py",))
coder.load()

#coder.run()
event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, QtCore.Qt.Key_F5, QtCore.Qt.NoModifier)
coder.keyPressEvent(event)

monkeypatch.setattr(QtWidgets.QFileDialog, "getOpenFileName", lambda *args: "test_code2.py")
monkeypatch.setattr(QtWidgets.QFileDialog, "getOpenFileName", lambda *args: ("test_code2.py",))
coder.load()
coder.tabs.setCurrentIndex(1)

Expand Down Expand Up @@ -826,10 +826,10 @@ def handle_load_existing(self: AddFilesDialog):
monkeypatch.setattr(AddFilesDialog, "exec", add_file(str(files[2])))
plotting_window.addFiles()

monkeypatch.setattr(QtWidgets.QFileDialog, "getSaveFileName", lambda *args: "save")
monkeypatch.setattr(QtWidgets.QFileDialog, "getSaveFileName", lambda *args: ("save",))
plotting_window.save()

monkeypatch.setattr(QtWidgets.QFileDialog, "getOpenFileName", lambda *args: "save.json")
monkeypatch.setattr(QtWidgets.QFileDialog, "getOpenFileName", lambda *args: ("save.json",))
plotting_window.load()

properties = ["strain_energy", "contractility", "polarity", "99_percentile_deformation", "99_percentile_force"]
Expand Down

0 comments on commit 133ca00

Please sign in to comment.