Skip to content

Expand assert_* functions to work with all signal types#711

Merged
jsouter merged 3 commits intomainfrom
test-assert-functions
Jan 17, 2025
Merged

Expand assert_* functions to work with all signal types#711
jsouter merged 3 commits intomainfrom
test-assert-functions

Conversation

@jsouter
Copy link
Contributor

@jsouter jsouter commented Dec 18, 2024

Fixes #707
Fixes #717

Expands OneOfEveryThingDevice into a StandardDetector so we can call read_configuration, and adds tests to tests/core/test_signal.py.

pytest.approx does not work on a whole dict when Tables are present, so now having to manually loop over each key in a dict[str, Reading], but now assert_reading, assert_value and assert_configuration work with arrays and table types.

@jsouter jsouter force-pushed the test-assert-functions branch from 88cd1b6 to fb82b42 Compare December 18, 2024 10:45
@jsouter jsouter linked an issue Dec 18, 2024 that may be closed by this pull request
@jsouter jsouter force-pushed the test-assert-functions branch from fb82b42 to 9105b63 Compare December 18, 2024 10:48
@jsouter jsouter requested a review from coretl December 18, 2024 10:52
@jsouter jsouter force-pushed the test-assert-functions branch 4 times, most recently from a88e533 to 81f951f Compare December 19, 2024 14:52
@coretl
Copy link
Collaborator

coretl commented Dec 20, 2024

#714 adds pytest assert rewriting, so you can ditch the custom error messages, and also an ApproxTable class used in MonitorQueue which could be used here instead of the is_same function

@jsouter jsouter force-pushed the test-assert-functions branch from 81f951f to 93fdbf9 Compare January 6, 2025 13:35
@jsouter jsouter requested a review from coretl January 6, 2025 13:42
@jsouter jsouter force-pushed the test-assert-functions branch from 93fdbf9 to c7159aa Compare January 6, 2025 14:45
@kivel
Copy link
Contributor

kivel commented Jan 6, 2025

This might link to #710

@coretl
Copy link
Collaborator

coretl commented Jan 7, 2025

This might link to #710

The ophyd_async.testing module (and ophyd_async.*.testing modules) are the only places that should use assert, as they are meant for tests, and we want pytest to do its assert rewriting, so must actually use an assert

Copy link
Collaborator

@coretl coretl left a comment

Choose a reason for hiding this comment

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

One minor comment then we're good to go!

@jsouter jsouter force-pushed the test-assert-functions branch from 840dd23 to 714d117 Compare January 9, 2025 08:23
@jsouter jsouter requested a review from coretl January 14, 2025 09:48
@jsouter jsouter force-pushed the test-assert-functions branch from 714d117 to 0d040a6 Compare January 14, 2025 09:57
@jsouter jsouter force-pushed the test-assert-functions branch from 0d040a6 to 0057179 Compare January 17, 2025 08:51
@coretl
Copy link
Collaborator

coretl commented Jan 17, 2025

Feel free to merge this when you're ready

@jsouter jsouter merged commit 5712705 into main Jan 17, 2025
22 checks passed
@jsouter jsouter deleted the test-assert-functions branch January 17, 2025 09:06
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.

Remove _generate_assert_error_msg and its usage now we have pytest assert rewriting Use the OneOfEverythingDevice to check the assert functions

3 participants