Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve (or document) _do_test #5

Open
JPHutchins opened this issue Feb 12, 2024 · 0 comments
Open

Improve (or document) _do_test #5

JPHutchins opened this issue Feb 12, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@JPHutchins
Copy link
Owner

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!

@JPHutchins JPHutchins added the enhancement New feature or request label Feb 12, 2024
@JPHutchins JPHutchins self-assigned this Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant