Skip to content

Improve (or document) _do_test #5

@JPHutchins

Description

@JPHutchins

There's this confusing _do_test function that I've duplicated throughout the tests. It ends up making a lot of the unit tests look like magic and doesn't necessarily help someone if they are using the unit tests to understand normal usage of the library.

def test_EchoWriteRequest() -> None:
    _do_test(
        smpos.EchoWriteRequest,
        smphdr.OP.WRITE,
        oscmd.ECHO,
        {"d": "Hello world!"},
    )

Nothing is accessed, asserted, etc.

I feel like the tests themselves should be updated to at least show that the CBOR payload members are accessible as part of the type:

def test_EchoWriteRequest() -> None:
    r = _do_test(
        smpos.EchoWriteRequest,
        smphdr.OP.WRITE,
        oscmd.ECHO,
        {"d": "Hello world!"},
    )
    assert r.d == "Hello world!"

Further, _do_test should be generalized, rewritten with better variable names, comments etc. if the code cannot be made more legible, so that maintainers don't have to copy it to each test suite.

_do_test ITSELF should be unit tested if tests depend on it!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions