-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
manually set the text format to plain text in error #1546
Conversation
I have the bones set up for a test, but the test hits the segfault I describe above. This will likely need some other fix |
I'm not seeing this on windows with pyqt5. What toolkit are you seeing that behavior with? And if the segfault is persistent, there is something horrible going on so that needs a separate issue. |
I honestly dont know why I bothered but I dug into the code to realize that It looks like we might actually be able to replace the |
I'm not seeing this either. Your fix works for me on windows with python 3.6 and pyqt5 and I just see the one dialog with the correct/expected text. |
We cant easily use |
I tried locally with Ubuntu and pyqt5 and everything is exactly as I would expect. It seems to be a macos specific thing On macOS, I git cleaned and create a fresh edm env and ran an example on master. I still see 2 dialogs and the segfault when trying to close one of them. I believe there is a bug here (potentially at the qt level) with macOS that is unrelated to the changes made in this PR. I will open an issue, but I am unsure what to do with this PR for the test |
I pushed hoping to see if the macOS CI would have the same issue I was seeing. Unfortunately, the appveyor build has no logs (although it did fail). Seemingly orthogonally, the Ubuntu pyside2 GH action is failing on a completely different test (????):
|
traitsui/tests/test_editor.py
Outdated
def test_editor_error_msg(self): | ||
from pyface.toolkit import toolkit_object | ||
from pyface.qt import QtGui | ||
from traits.api import HasTraits, Range | ||
|
||
from traitsui.testing.api import ( | ||
KeyClick, KeySequence, Textbox, UITester | ||
) | ||
|
||
ModalDialogTester = toolkit_object( | ||
"util.modal_dialog_tester:ModalDialogTester" | ||
) | ||
|
||
class Foo(HasTraits): | ||
x = Range(low=0.0, high=1.0, value=0.5, exclude_low=True) | ||
|
||
foo = Foo() | ||
tester = UITester() | ||
with tester.create_ui(foo) as ui: | ||
|
||
x_range = tester.find_by_name(ui, "x") | ||
x_range_textbox = x_range.locate(Textbox()) | ||
|
||
for _ in range(3): | ||
x_range_textbox.perform(KeyClick('Backspace')) | ||
|
||
x_range_textbox.perform(KeySequence('0.0')) | ||
|
||
def trigger_error(): | ||
x_range_textbox.perform(KeyClick('Enter')) | ||
|
||
def check_and_close(mdtester): | ||
try: | ||
with mdtester.capture_error(): | ||
self.assertTrue( | ||
mdtester.has_widget( | ||
text="The 'x' trait of a Foo instance must be " | ||
"0.0 < a floating point number <= 1.0, " | ||
"but a value of 0.0 <class 'float'> was " | ||
"specified.", | ||
type_=QtGui.QMessageBox, | ||
) | ||
) | ||
finally: | ||
mdtester.close(accept=True) | ||
self.assertTrue(mdtester.dialog_was_opened) | ||
|
||
mdtester = ModalDialogTester(trigger_error) | ||
mdtester.open_and_run(check_and_close) | ||
self.assertTrue(mdtester.dialog_was_opened) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The level of complexity for this test now seems to far exceed what it is trying to test :/
Perhaps the test could be trivia and just reach into Qt and make sure the textFormat
property gets set? Like I do in enthought/pyface#907
This test will still require ModalDialogTester as the error
method on editor does not return anything. It will only be accessible via triggering the dialog to pop up. I could replace the assert statement with
self.assertEqual(mdtester.get_dialog_widget().textFormat(), QtCore.Qt.PlainText)
but that doesn't really feel any better
The macOS weirdness I am seeing feels like an orthogonal problem, and I am still very unclear on what the cause is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macOS weirdness I am seeing feels like an orthogonal problem, and I am still very unclear on what the cause is.
Yes. Definitely something strange going on here.
Checking the text of the dialog in the test seems OK to me (or is that not working consistently?). I think the bigger issue is the Qt-specific nature of the test code. I know we're not running Wx CI jobs, but it still feels a bit wrong to have a bunch of local imports and Qt specific code in a single test. Do you plan to remove the local imports before merging this? |
Yeah I will clean up the imports and specify the test requires Qt specifically before merging. |
Yes, the example from the issue causes a segfault when I run it on macOS. I believe that's a separate issue. |
Thank you very much for confirming that! I think I will just skip this test on OSX on CI then and open a separate issue |
…ialog tester, or are on mac os
CI is still failing on Ubuntu/Pyside2 in a seemingly unrelated test... When I run the relevant test module thought I do see the following: |
Given all the crazy failures you're seeing, now might be a good time to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look OK. Anything left here?
I think we are good to go? I am confused why the |
Oooh boy. Intermittent failures are the best, huh? We should probably just leave an issue and move on. |
I've opened #1551 |
fixes #1543
Note I am observing a segfault when I set the slider to 0 in the example given in the issue and then close the information dialog (this occurs both with and without the changes of this PR)
Im not sure why we weren't previously using
information
from thepyface.api
here (see: https://github.com/enthought/pyface/blob/65813858730a61f25618e98669bcc5347d44935a/pyface/message_dialog.py#L15-L43)In any case, now in order to call
setTextFormat
we would not be ably to use pyface directly anyway / we can no longer call the static functionQtGui.QMessageBox.information
.This is what I currently see if I set the slider to 0.0:
As opposed to this from before:
I am unsure why 2 dialogs show up (this is probably a separate bug?)
A test for this would likely require UITester + ModalDialogTester to look at the displayed text in the created modal dialog. I will investigate this now