Skip to content

Commit 9c7b738

Browse files
TEMP: Test changes
1 parent 25fa7f6 commit 9c7b738

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

tests/test_records.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,14 @@ def on_update_recursive_set_test_func(
693693
async def on_update_func(new_val):
694694
log("CHILD: on_update_func started")
695695
record.set(0, process=False)
696+
conn.send("C") # "Callback"
696697
log("CHILD: on_update_func ended")
697698

698699
record = builder.Action(
699700
"ACTION",
700701
on_update=on_update_func,
701702
blocking=True,
702-
initial_value=1 # A non-zero value, to check it changes
703+
initial_value=1 # A non-zero value, to check it changes
703704
)
704705

705706
dispatcher = asyncio_dispatcher.AsyncioDispatcher()
@@ -717,8 +718,7 @@ async def on_update_func(new_val):
717718

718719
log("CHILD: Received exit command, child exiting")
719720

720-
721-
async def test_on_update_recursive_set(self, capsys):
721+
async def test_on_update_recursive_set(self):
722722
"""Test that on_update functions correctly when the on_update
723723
callback sets the value of the record again (with process=False).
724724
See issue #201"""
@@ -747,17 +747,22 @@ async def test_on_update_recursive_set(self, capsys):
747747

748748
record = f"{device_name}:ACTION"
749749

750+
val = await caget(record)
751+
752+
assert val == 1, "ACTION record did not start with value 1"
753+
750754
await caput(record, 1, wait=True)
751755

752756
val = await caget(record)
753757

754758
assert val == 0, "ACTION record did not return to zero value"
755759

760+
# Expect one "C"
761+
select_and_recv(parent_conn, "C")
756762

757-
# Now check that only one set of log messages was printed
758-
captured = capsys.readouterr()
759-
instances = re.findall("CHILD: on_update_func started", captured.out)
760-
assert len(instances) == 1, "Multiple log messages detected"
763+
# ...But if we receive another we know there's a problem
764+
if parent_conn.poll(5): # Shorter timeout to make this quicker
765+
pytest.fail("Received unexpected second message")
761766

762767
finally:
763768
log("PARENT:Sending Done command to child")

0 commit comments

Comments
 (0)