Skip to content

PlugValueWidgetTest : Fix handling of background updates (alternative approach) - #7082

Open
johnhaddon wants to merge 1 commit into
GafferHQ:mainfrom
johnhaddon:plugValueWidgetTestFixesConservativeApproach
Open

PlugValueWidgetTest : Fix handling of background updates (alternative approach)#7082
johnhaddon wants to merge 1 commit into
GafferHQ:mainfrom
johnhaddon:plugValueWidgetTestFixesConservativeApproach

Conversation

@johnhaddon

Copy link
Copy Markdown
Member

This fixes the same test failures as #7081, but in a more conservative way, affecting only the tests which used PlugValueWidgetTest.waitForUpdate(). The fundamental issue is how we deal with testing UI updates involving LazyMethod and BackgroundMethod, where in both cases we need to wait for the UI to update before we can make our assertions. We've taken two main approaches to that :

1.TestCase.waitForIdle() : This just runs the Qt event loop for a little bit and then stops. And calls to ParallelAlgo::callOnUIThread() are serviced by the regular handler in EventLoop.py. This has benefits in that it's pretty simple, and you don't need to know how many UI thread calls you're expecting. But it's also pretty vague - it's not clear how much idling is enough before we can make our assertions, so we're always in danger of not idling enough.
2. ParallelAlgoTest.UIThreadCallHandler().assertCalled() : This is independent of the event loop. It installs its own UI thread call handler, and syncs that with calls to assertCalled(). It's very controlled, and always waits until the required updates are complete. But it's also tied quite closely to the implementation of the widgets we're testing, because we need to know how many UI thread calls to expect.

Before, each test could decide what approach it wanted to take. But #7081 forces everything into option 2, meaning that tests that expect waitForIdle() to execute UI thread calls will fail. It would be great to settle on one approach, but that's too much work right now. And maybe a different approach entirely would be better anyway - something like the assertEventually() we use for interactive render tests?

Anyway, to summarise, I'm proposing that this PR replaces #7081.

This fixes test failures that looked like this :

```
Traceback (most recent call last):
  File "D:\a\gaffer\gaffer\build\python\GafferUITest\PlugValueWidgetTest.py", line 453, in testContextTrackerUpdates
    self.waitForUpdate( widget )
  File "D:\a\gaffer\gaffer\build\python\GafferUITest\PlugValueWidgetTest.py", line 62, in waitForUpdate
    handler.assertCalled()
  File "D:\a\gaffer\gaffer\build\python\GafferTest\ParallelAlgoTest.py", line 92, in assertCalled
    self.receive( timeout )()
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\gaffer\gaffer\build\python\GafferTest\ParallelAlgoTest.py", line 86, in receive
    raise AssertionError( "UIThread call not made within {} seconds".format( timeout ) )
AssertionError: UIThread call not made within 30.0 seconds
```

Our old approach of calling `waitForUpdate()` after running the code to trigger
the update was bogus - it was possible for the update to have finished before we
even got to calling `waitForUpdate()`. By triggering the update from _inside_ the
UIThreadCallHandler's scope we avoid this possibility.
@johnhaddon johnhaddon self-assigned this Aug 7, 2026
@github-project-automation github-project-automation Bot moved this to Pending Review in Work in Progress Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

1 participant