How to close QFileDialog.getOpenFileName in QTest?

I am developing an application in Python 3.5 using PyQt4, and I want to test it with unit test using QTest. So far, I have managed to do whatever I want with QTest, except for this problem:

My window is like a folder button, when you click on it, the File dialog box opens to select the folder (classic). This (more or less) is written like this in my code:

self.file_dialog = QtGui.QFileDialog()
[...]    
tmp_path = self.file_dialog.getOpenFileName(self, caption='toto', filter="*.csv")

My problem is that in QTest I cannot find a way to close this dialog when it appears.

I already tried calling the close () or reject () method (directly or using a single shot timer), but none of them work ...

Are there any solutions that I haven't thought about? I would not mind closing all windows if necessary (but I also can not do this)

Thank!

+4
source share

Source: https://habr.com/ru/post/1671272/


All Articles