Skip to content
New issue

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

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

Already on GitHub? # to your account

make Schema.__eq__ deterministic #316

Merged

Conversation

dtao
Copy link
Contributor

@dtao dtao commented Dec 6, 2017

This adds a test to highlight the issue raised in #315 and proposes a solution: instead of comparing str(self.schema) with str(other), just compare schema attributes directly.

@coveralls
Copy link

coveralls commented Dec 6, 2017

Coverage Status

Coverage decreased (-0.1%) to 95.28% when pulling be867c5 on dtao:dtao/make-schema-equality-deterministic into 9204e83 on alecthomas:master.

dtao added 2 commits December 6, 2017 13:06
This fills in missing test coverage to ensure the __eq__ method does not
return True in some potentially unexpected cases (these tests would fail
before be867c5).
Previously only the __eq__ method was implemented, which could lead to
surprising behavior e.g.:

    Schema('foo') == Schema('foo')  # True
    Schema('foo') != Schema('foo')  # True

This adds the __ne__ method so that these operators are complementary as
one might expect.
@coveralls
Copy link

coveralls commented Dec 6, 2017

Coverage Status

Coverage increased (+0.009%) to 95.388% when pulling 0435511 on dtao:dtao/make-schema-equality-deterministic into 9204e83 on alecthomas:master.

@dtao
Copy link
Contributor Author

dtao commented Dec 6, 2017

Update: after adding some more tests for this, I noticed that the __ne__ method was not defined; so I implemented that as well. (Now there are quite a few tests that fail before these changes!)

Copy link
Collaborator

@tusharmakkar08 tusharmakkar08 left a comment

Choose a reason for hiding this comment

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

Hey @dtao

Thanks for the prompt response. This PR looks good to me. Please squash your commits and let's get it merged.
Thanks.

@alecthomas
Copy link
Owner

@tusharmakkar08 you should be able to Squash and merge the branch through GitHub:

image

@tusharmakkar08
Copy link
Collaborator

@alecthomas Didn't know it existed 😅

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants