Skip to content

test: switch to regex rather than asserting against whole object #497

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

Merged
merged 8 commits into from
Apr 20, 2023

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Apr 18, 2023

The goal of this test is to assert against the helper:

    def __repr__(self):
        return "ClientOptions: " + repr(self.__dict__)

Rather than asserting against the whole object which is fragile, this just uses a regex to make sure that we've populated the prefix and the keys.

Fixes #449, #492


FYI: here's the commit for the original test, which I believe a simple regex that asserts the basic structure of the serialized object is closer to the spirit of b6cea3c

@bcoe bcoe requested review from a team as code owners April 18, 2023 17:35
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Apr 18, 2023
@bcoe bcoe requested a review from vchudnov-g April 18, 2023 18:54
@bcoe bcoe changed the title test: switch to asserting against set of keys test: switch to regex rather than asserting against whole object Apr 19, 2023
@bcoe bcoe requested a review from vchudnov-g April 19, 2023 14:20
Copy link
Contributor

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

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

Yeah, I'm guessing the new structure probably captures the original intent of the test. But that's not to say that the key check you introduced earlier is bad; maybe it's worth keeping as an additional test?

@bcoe
Copy link
Contributor Author

bcoe commented Apr 19, 2023

But that's not to say that the key check you introduced earlier is bad; maybe it's worth keeping as an additional test?

One argument I'd make for not keeping it, is it does mean the test will need to be updated as we update the options bag over time. I was wondering if this is needed, given what we're really testing is the serialization.

@vchudnov-g
Copy link
Contributor

test_repr tests the serialization, so we can leave that as it now stands after your changes.

The set comparison you introduced earlier and then removed would be an additional test on the options object. I generally agree we don't want to have to make a lot of dependent manual changes when something fundamental changes. However, if we don't check anywhere else for the keys that are in this bag, this would be a good signal in case something accidentally gets deleted. I don't know whether we test these keys elsewhere. I assume new options don't get added all that frequently? (real question; I don't know)

So I could go either way, as I'm not super familiar with how these options are used or tested. But my inclination is to add back (in a separate test) the set-based key check you had earlier, precisely as a safequard against accidental deletion. But I'm certainly not fixated on this, and am happy to hear reasons not to. @parthea , WDYT?

@bcoe
Copy link
Contributor Author

bcoe commented Apr 20, 2023

The set comparison you introduced earlier and then removed would be an additional test on the options object.

Okay, I've added it back.

@bcoe bcoe merged commit 6acb3a9 into main Apr 20, 2023
@bcoe bcoe deleted the tweak-test-slightly branch April 20, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assert in test_repr is always true
3 participants