Repository navigation
Conversation
Collaborator
Author
|
Converting back to draft, I've got a simplified design in the works, I'll re-request review when it's ready... |
init_devices(mock=...), connect_devices and ensure_connected take bool | Mapping[type[Device], bool | type[DeviceMock]], and Device.connect(mock=...) also accepts a DeviceMock instance. Each Device looks itself up by the nearest class in its MRO. True uses the Device's default mock, a DeviceMock subclass uses that class, False connects for real. An entry under Device is the default for the first level only; children otherwise inherit their parent's decision unless they have their own entry. Signal and Command types cannot be keys (TypeError): they always follow their parent Device. This is the API agreed in bluesky#1429. - DeviceConnector.connect(device, mock, timeout, force_reconnect) replaces connect_real and connect_mock; connectors branch on mock.mocked. Out-of-tree overrides of the old names are no longer called. - DeviceMock(name="", parent=None, mocked=True, *, mock_types=None) - Children connect in parallel with the caller's timeout and force_reconnect, also under a mocked parent; when nothing below can be real they connect serially, which is faster for large mock trees - Device.connect caches mocked as well as real connects (same mock class, mocked and mock_types, last connect succeeded); an uncached connect connects everything below it again. A second connect(mock=True) keeps mock values and call records; force_reconnect=True rebuilds them - get_mock raises if the last connect has not succeeded - DeviceMock.connect hook runs after the connector, so Signal and Command mocks get it too; SignalR drops its cache when its backend is replaced - LazyMock deprecated via DeprecationWarning - docs: per-type overrides, the default mock rule, caching and re-connect caveats - CLAUDE.md: keep each CI unit/system test stage to about a minute Assisted-by: Claude Opus 5.5
coretl
marked this pull request as ready for review
November 11, 2026 14:04
Collaborator
Author
|
@jwlodek this is now ready to review |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow the mock class to be chosen per device type anywhere in a device tree, including children that only exist after connect (PVI, Tango, Command).
Supersedes #1429, which lets
init_deviceschoose mocks for the devices it creates but cannot reach children further down the tree.Usage
ensure_connected(..., mock={...})takes the same argument. Both validatemockat runtime and raiseTypeErrorfor a bad one;Device.connectis checked by static analysis only.Behaviour changes
init_devices(mock=...),ensure_connected(mock=...)and the newconnect_devicestakebool | Mapping[type[Device], bool | type[DeviceMock]], so you can mix real and mocked Devices anywhere in a tree (e.g.{Device: True, Motor: False}). An entry underDeviceis the default for the first level only.ensure_connectedno longer accepts aDeviceMockinstance.Device.connect(mock=...)takesbool | DeviceMock; aDeviceMockinstance'smockedandmock_typesdecide the Device and its children.DeviceMock.__init__(name="", parent=None, mocked=True, *, mock_types=None). A real Device holds aDeviceMocktoo, soget_mockworks on any connected Device and raises if its last connect has not succeeded.DeviceConnector.connect_mockandDeviceConnector.connect_realare replaced by oneDeviceConnector.connect(device, mock, timeout, force_reconnect); overrides branch onmock.mockedand callsuper().connect(...). An out-of-tree connector that still overrides the old names is silently ignored, so its backend never connects: rename the override.connect(mock=True)with the same choice keeps mock values and call records; passforce_reconnect=Trueto rebuild. Any connect that is not cached connects everything below it again.timeoutandforce_reconnect, also under a mocked parent.DeviceMock.connecthook now runs for Signals and Commands too.LazyMockis deprecated; useDeviceMock.AI Disclaimer
The code and this description were generated with AI and reviewed/tweaked by the author.