Skip to content

test: start mocked client with no current scan to prevent mock leakage into scan_item#1243

Open
wyzula-jan wants to merge 1 commit into
mainfrom
fix/mocked-client-no-current-scan
Open

test: start mocked client with no current scan to prevent mock leakage into scan_item#1243
wyzula-jan wants to merge 1 commit into
mainfrom
fix/mocked-client-no-current-scan

Conversation

@wyzula-jan

@wyzula-jan wyzula-jan commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

There was leak of scan_item in tests, which would look like this in CI (it would pass anyway but should be fixed):

Traceback (most recent call last):
  File "/home/runner/work/bec_widgets/bec_widgets/bec_widgets/bec_widgets/widgets/plots/waveform/waveform.py", line 1673, in update_sync_curves
    x_data = self._get_x_data(device_name, device_entry)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/bec_widgets/bec_widgets/bec_widgets/bec_widgets/widgets/plots/waveform/waveform.py", line 2255, in _get_x_data
    signal_x = self.entry_validator.validate_signal(device_x, None)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/bec_widgets/bec_widgets/bec_widgets/bec_widgets/utils/entry_validator.py", line 17, in validate_signal
    raise ValueError(f"Device '{name}' not found in current BEC session")
ValueError: Device '<MagicMock name='ScanManager().scan_storage.current_scan.metadata.__getitem__().__getitem__()' id='140115129984272'>' not found in current BEC session

Copilot AI review requested due to automatic review settings July 15, 2026 14:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the shared mocked_client test fixture so a freshly mocked BEC session starts with queue.scan_storage.current_scan = None, preventing MagicMock “current scan” objects from being unintentionally adopted as real scan_items by widgets and later causing noisy async Qt-slot tracebacks during unit tests.

Changes:

  • Initialize bec_dispatcher.client.queue.scan_storage.current_scan to None in the shared mocked_client fixture.
  • Add an explanatory comment documenting why the fixture sets current_scan to None.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wyzula-jan wyzula-jan self-assigned this Jul 15, 2026
@wyzula-jan
wyzula-jan requested a review from a team July 15, 2026 14:15
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants