How to handle modal dialog in pytest-qt without mocking the dialogHow do I check whether a file exists without exceptions?How to print without newline or space?How to get the filename without the extension from a path in Python?How to print the full traceback without halting the program?tkinter default button in a widgetPySide Qt Creator message dialog exitPyQt QDialog - returning a value and closing from dialogPyQt Multi Threading, Cannot create children for a parentCan I force matplotlib to block in a PyQt thread / process?Windows Automaton - InvokePattern blocking execution until everything has completed
The use of "I" and "we" used in the same sentence and other questions
Layout of complex table
Are Finite Automata Turing Complete?
How often can a PC check with passive perception during a combat turn?
How can Charles Proxy change settings without admin rights after first time?
Why does Darth Sidious need bodyguards?
How should I behave to assure my friends that I am not after their money?
MH370 blackbox - is it still possible to retrieve data from it?
In the Marvel universe, can a human have a baby with any non-human?
What is this particular type of chord progression, common in classical music, called?
Do equal angles necessarily mean a polygon is regular?
What is this opening trap called, and how should I play afterwards? How can I refute the gambit, and play if I accept it?
Is this one of the engines from the 9/11 aircraft?
Does squid ink pasta bleed?
How to perform Login Authentication at the client-side?
How to positively portray high and mighty characters?
Why cruise at 7000' in an A319?
What would Earth look like at night in medieval times?
Alphabet completion rate
Using symmetry of Riemann tensor to vanish components
C-152 carb heat on before landing in hot weather?
Every infinite linearly ordered set has two disjoint infinite subsets
What do you call the action of someone tackling a stronger person?
Is there a short way to compare many values mutually at same time without using multiple 'and's?
How to handle modal dialog in pytest-qt without mocking the dialog
How do I check whether a file exists without exceptions?How to print without newline or space?How to get the filename without the extension from a path in Python?How to print the full traceback without halting the program?tkinter default button in a widgetPySide Qt Creator message dialog exitPyQt QDialog - returning a value and closing from dialogPyQt Multi Threading, Cannot create children for a parentCan I force matplotlib to block in a PyQt thread / process?Windows Automaton - InvokePattern blocking execution until everything has completed
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using pytest-qt to automate the testing of a PyQt GUI. The dialogs need to be handled as a part of the testing(dialogs should not be mocked).
For example, file dialog that comes after a button-click has to be handled. There are 2 problems
After the button click command, the program control goes to the event handler and not to the next line where I can try to send mouseclick/keystrokes to the dialog.
Since the QDialog is not added to the main widget, it is not being listed among the children of the main widget. So how to get the reference of the QDialog?
I tried multi-threading but that didn't work, later I found that QObjects are not thread-safe.
def test_filedialog(qtbot, window):
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
print("After mouse click")
#This is where I need to get the reference of QDialog and handle it
python pyqt4 ui-automation black-box-testing pytest-qt
add a comment |
I am using pytest-qt to automate the testing of a PyQt GUI. The dialogs need to be handled as a part of the testing(dialogs should not be mocked).
For example, file dialog that comes after a button-click has to be handled. There are 2 problems
After the button click command, the program control goes to the event handler and not to the next line where I can try to send mouseclick/keystrokes to the dialog.
Since the QDialog is not added to the main widget, it is not being listed among the children of the main widget. So how to get the reference of the QDialog?
I tried multi-threading but that didn't work, later I found that QObjects are not thread-safe.
def test_filedialog(qtbot, window):
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
print("After mouse click")
#This is where I need to get the reference of QDialog and handle it
python pyqt4 ui-automation black-box-testing pytest-qt
try with:print(QtGui.QApplication.topLevelWidgets())
– eyllanesc
Mar 25 at 23:24
Thanks, @eyllanesc I can try that for getting the dialog reference. But I need to solve the first issue to try this.
– Nagendra prasath
Mar 26 at 8:50
add a comment |
I am using pytest-qt to automate the testing of a PyQt GUI. The dialogs need to be handled as a part of the testing(dialogs should not be mocked).
For example, file dialog that comes after a button-click has to be handled. There are 2 problems
After the button click command, the program control goes to the event handler and not to the next line where I can try to send mouseclick/keystrokes to the dialog.
Since the QDialog is not added to the main widget, it is not being listed among the children of the main widget. So how to get the reference of the QDialog?
I tried multi-threading but that didn't work, later I found that QObjects are not thread-safe.
def test_filedialog(qtbot, window):
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
print("After mouse click")
#This is where I need to get the reference of QDialog and handle it
python pyqt4 ui-automation black-box-testing pytest-qt
I am using pytest-qt to automate the testing of a PyQt GUI. The dialogs need to be handled as a part of the testing(dialogs should not be mocked).
For example, file dialog that comes after a button-click has to be handled. There are 2 problems
After the button click command, the program control goes to the event handler and not to the next line where I can try to send mouseclick/keystrokes to the dialog.
Since the QDialog is not added to the main widget, it is not being listed among the children of the main widget. So how to get the reference of the QDialog?
I tried multi-threading but that didn't work, later I found that QObjects are not thread-safe.
def test_filedialog(qtbot, window):
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
print("After mouse click")
#This is where I need to get the reference of QDialog and handle it
python pyqt4 ui-automation black-box-testing pytest-qt
python pyqt4 ui-automation black-box-testing pytest-qt
asked Mar 25 at 11:16
Nagendra prasathNagendra prasath
13 bronze badges
13 bronze badges
try with:print(QtGui.QApplication.topLevelWidgets())
– eyllanesc
Mar 25 at 23:24
Thanks, @eyllanesc I can try that for getting the dialog reference. But I need to solve the first issue to try this.
– Nagendra prasath
Mar 26 at 8:50
add a comment |
try with:print(QtGui.QApplication.topLevelWidgets())
– eyllanesc
Mar 25 at 23:24
Thanks, @eyllanesc I can try that for getting the dialog reference. But I need to solve the first issue to try this.
– Nagendra prasath
Mar 26 at 8:50
try with:
print(QtGui.QApplication.topLevelWidgets())
– eyllanesc
Mar 25 at 23:24
try with:
print(QtGui.QApplication.topLevelWidgets())
– eyllanesc
Mar 25 at 23:24
Thanks, @eyllanesc I can try that for getting the dialog reference. But I need to solve the first issue to try this.
– Nagendra prasath
Mar 26 at 8:50
Thanks, @eyllanesc I can try that for getting the dialog reference. But I need to solve the first issue to try this.
– Nagendra prasath
Mar 26 at 8:50
add a comment |
1 Answer
1
active
oldest
votes
It can be done using QTimer
.
def test_filedialog(qtbot, window):
def handle_dialog():
# get a reference to the dialog and handle it here
QTimer.singleShot(500, handle_dialog)
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
Refer this link for more details
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336575%2fhow-to-handle-modal-dialog-in-pytest-qt-without-mocking-the-dialog%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It can be done using QTimer
.
def test_filedialog(qtbot, window):
def handle_dialog():
# get a reference to the dialog and handle it here
QTimer.singleShot(500, handle_dialog)
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
Refer this link for more details
add a comment |
It can be done using QTimer
.
def test_filedialog(qtbot, window):
def handle_dialog():
# get a reference to the dialog and handle it here
QTimer.singleShot(500, handle_dialog)
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
Refer this link for more details
add a comment |
It can be done using QTimer
.
def test_filedialog(qtbot, window):
def handle_dialog():
# get a reference to the dialog and handle it here
QTimer.singleShot(500, handle_dialog)
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
Refer this link for more details
It can be done using QTimer
.
def test_filedialog(qtbot, window):
def handle_dialog():
# get a reference to the dialog and handle it here
QTimer.singleShot(500, handle_dialog)
qtbot.mouseClick(window.browseButton, QtCore.Qt.LeftButton, delay=1)
Refer this link for more details
answered Mar 29 at 16:27
Nagendra prasathNagendra prasath
13 bronze badges
13 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336575%2fhow-to-handle-modal-dialog-in-pytest-qt-without-mocking-the-dialog%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
try with:
print(QtGui.QApplication.topLevelWidgets())
– eyllanesc
Mar 25 at 23:24
Thanks, @eyllanesc I can try that for getting the dialog reference. But I need to solve the first issue to try this.
– Nagendra prasath
Mar 26 at 8:50