Skip to content

Commit

Permalink
Merge pull request #1 from bluesky/fix-unstage-all-tests
Browse files Browse the repository at this point in the history
Fix pre-processor unstage_all behaviour in tests
  • Loading branch information
coretl committed Oct 20, 2023
2 parents bc48c68 + a2c767c commit bb9fb37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bluesky/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,11 +918,11 @@ def new_gen():
else:
return None, None

def unstage_all():
def inner_unstage_all():
yield from unstage_all(*reversed(devices_staged))

return (yield from finalize_wrapper(plan_mutator(plan, inner),
unstage_all()))
inner_unstage_all()))


def stage_wrapper(plan, devices):
Expand Down
14 changes: 11 additions & 3 deletions bluesky/tests/test_new_examples.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
from collections import defaultdict
import time as ttime
from typing import Dict
from typing import Dict, List
import pytest
from bluesky import Msg, RunEngineInterrupted
from bluesky.plan_stubs import (
Expand Down Expand Up @@ -375,11 +375,19 @@ def plan():

processed_plan = list(lazily_stage_wrapper(plan()))

expected = [Msg('stage', det1), Msg('read', det1), Msg('read', det1),
expected_plan: List[Msg] = [Msg('stage', det1), Msg('read', det1), Msg('read', det1),
Msg('stage', det2), Msg('read', det2), Msg('unstage', det2),
Msg('unstage', det1)]

assert processed_plan == expected
# Prevent issue with unstage_all creating a randomly assigned group
assert len(processed_plan) == len(expected_plan)
group: str = ""
for i in range(len(expected_plan)):
expected, actual = expected_plan[i], processed_plan[i]
assert actual.command == expected.command
assert actual.obj == expected.obj
groups = {msg.kwargs["group"] for msg in processed_plan if msg.command == "unstage"}
assert len(groups) == 1 # All unstage messages are in the same group


def test_subs():
Expand Down

0 comments on commit bb9fb37

Please sign in to comment.