Skip to content

make Schema.__eq__ deterministic#316

Merged
tusharmakkar08 merged 4 commits intoalecthomas:masterfrom
dtao:dtao/make-schema-equality-deterministic
Dec 7, 2017
Merged

make Schema.__eq__ deterministic#316
tusharmakkar08 merged 4 commits intoalecthomas:masterfrom
dtao:dtao/make-schema-equality-deterministic

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 😅

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.

4 participants