Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Add a testing helper which verifies the equality/hashing behavior supplied by with_cmp #4

Open
exarkun opened this issue Jun 14, 2014 · 3 comments

Comments

@exarkun
Copy link

exarkun commented Jun 14, 2014

One wants to unit test this sort of behavior but characteristic has enough information to automatically generate these tests in most cases.

Perhaps something like MyClassEqualityTests = make_equality_tests(MyClass)?

@hynek
Copy link
Owner

hynek commented Jun 14, 2014

That sounds great, pull request (for all three cases) maybe? :)

@hynek hynek added this to the 0.2 milestone Jun 15, 2014
@wallrj
Copy link

wallrj commented Jun 25, 2014

Twisted has testutils.ComparisonTestsMixin.assertNormalEqualityImplementation https://github.com/twisted/twisted/blob/trunk/twisted/test/testutils.py#L125

  • Are all those assertions strictly necessary?
  • Should we aim to generate a TestCase class which has separate test methods for all those assertions?
  • An example of where this is used is twisted.names.test.test_dns.MessageComparisonTests (https://github.com/twisted/twisted/blob/trunk/twisted/names/test/test_dns.py#L870). But it's painful to have to write a separate test method for comparison of each attribute. So I guess we need to aim to generate test methods for every combination of attribute and equality assertion.

With all that in mind, has anyone got any hints on the best way to implement this?

@hynek
Copy link
Owner

hynek commented Aug 17, 2014

Removing milestone. Feel free to submit a pull request once you’ve settled on an approach.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants