Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Versioning <https://semver.org/spec/v2.0.0.html>`_.
Unreleased_
-----------

Changed:

- `Improve string representation of RecordWrapper instances <../../pull/130>`

4.3.0_ - 2023-04-04
-------------------

Expand Down
3 changes: 1 addition & 2 deletions softioc/pythonSoftIoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def __call__(self, *specifiers):
return self.__builder(*specifiers)

def __str__(self):
return str(self.__builder)

return self.__device._name


class PythonDevice(object):
Expand Down
58 changes: 58 additions & 0 deletions tests/test_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,64 @@ def test_clear_records_too_late():
pytest.fail("Process did not terminate")


def str_ioc_test_func(device_name, conn):
builder.SetDeviceName(device_name)

record_name = "MyAI"

full_name = device_name + ":" + record_name

ai = builder.aIn(record_name)


log("CHILD: Created ai record: ", ai.__str__())

assert (
ai.__str__() == full_name
), f"Record name {ai.__str__()} before LoadDatabase did not match " \
f"expected string {full_name}"

builder.LoadDatabase()

assert (
ai.__str__() == full_name
), f"Record name {ai.__str__()} after LoadDatabase did not match " \
f"expected string {full_name}"

dispatcher = asyncio_dispatcher.AsyncioDispatcher()
softioc.iocInit(dispatcher)

assert (
ai.__str__() == full_name
), f"Record name {ai.__str__()} after iocInit did not match expected " \
f"string {full_name}"

conn.send("R") # "Ready"
log("CHILD: Sent R over Connection to Parent")



def test_record_wrapper_str():
"""Test that the __str__ method on the RecordWrapper behaves as expected,
both before and after loading the record database"""

ctx = get_multiprocessing_context()
parent_conn, child_conn = ctx.Pipe()

device_name = create_random_prefix()

ioc_process = ctx.Process(
target=str_ioc_test_func,
args=(device_name, child_conn),
)

ioc_process.start()


# Wait for message that IOC has started
# If we never receive R it probably means an assert failed
select_and_recv(parent_conn, "R")


def validate_fixture_names(params):
"""Provide nice names for the out_records fixture in TestValidate class"""
Expand Down