{"action":"created","issue":{"url":"https://api.github.com/repos/jaimegildesagredo/expects/issues/39","labels_url":"https://api.github.com/repos/jaimegildesagredo/expects/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/jaimegildesagredo/expects/issues/39/comments","events_url":"https://api.github.com/repos/jaimegildesagredo/expects/issues/39/events","html_url":"https://github.com/jaimegildesagredo/expects/issues/39","id":106235920,"number":39,"title":"not_to(equal) using == and not !=","user":{"login":"alejandrodob","id":5711098,"avatar_url":"https://avatars.githubusercontent.com/u/5711098?v=3","gravatar_id":"","url":"https://api.github.com/users/alejandrodob","html_url":"https://github.com/alejandrodob","followers_url":"https://api.github.com/users/alejandrodob/followers","following_url":"https://api.github.com/users/alejandrodob/following{/other_user}","gists_url":"https://api.github.com/users/alejandrodob/gists{/gist_id}","starred_url":"https://api.github.com/users/alejandrodob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alejandrodob/subscriptions","organizations_url":"https://api.github.com/users/alejandrodob/orgs","repos_url":"https://api.github.com/users/alejandrodob/repos","events_url":"https://api.github.com/users/alejandrodob/events{/privacy}","received_events_url":"https://api.github.com/users/alejandrodob/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-13T19:41:52Z","updated_at":"2015-09-23T17:43:18Z","closed_at":null,"body":"When using the matcher equal with a not, (e.g `expect(some_object).not_to(equal(another_object))` first the equal is performed with the `==` operator and then the result is operated with a boolean not. Internally this will call the `__eq__` method on the object to perform the comparison. However, when comparing two objects for inequality in Python with the `!=` operator, the method that will be called is `__ne__`. For most of the cases, this is ok, as `__ne__` will probably be calling `__eq__` (or maybe not, but anyway `not ==` should be equivalent to `!=` if the world made sense at all!).\r\n\r\nThis is not a big deal by itself, but sometimes one would expect a different behaviour of `not_to(equal())` than the current one. For example, if you're TDDing the `__eq__` and `__ne__` methods of a class (this just happened to me :D).\r\n\r\nI am not sure whether making `not_to(equal)` use the `!=` operator would be easy to implement or even would make sense at all but, if not, maybe having another matcher called `different` or `unequal` that actually performed the comparison with `!=` could fit.\r\n\r\nIf you think this could be of some value I would be glad to help implementing it.\r\n\r\nAnyway, I would like to thank you for this great library!"},"comment":{"url":"https://api.github.com/repos/jaimegildesagredo/expects/issues/comments/142676010","html_url":"https://github.com/jaimegildesagredo/expects/issues/39#issuecomment-142676010","issue_url":"https://api.github.com/repos/jaimegildesagredo/expects/issues/39","id":142676010,"user":{"login":"alejandrodob","id":5711098,"avatar_url":"https://avatars.githubusercontent.com/u/5711098?v=3","gravatar_id":"","url":"https://api.github.com/users/alejandrodob","html_url":"https://github.com/alejandrodob","followers_url":"https://api.github.com/users/alejandrodob/followers","following_url":"https://api.github.com/users/alejandrodob/following{/other_user}","gists_url":"https://api.github.com/users/alejandrodob/gists{/gist_id}","starred_url":"https://api.github.com/users/alejandrodob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alejandrodob/subscriptions","organizations_url":"https://api.github.com/users/alejandrodob/orgs","repos_url":"https://api.github.com/users/alejandrodob/repos","events_url":"https://api.github.com/users/alejandrodob/events{/privacy}","received_events_url":"https://api.github.com/users/alejandrodob/received_events","type":"User","site_admin":false},"created_at":"2015-09-23T17:43:18Z","updated_at":"2015-09-23T17:43:18Z","body":"Hi @jaimegildesagredo,\r\n\r\nI've worked on a couple of versions. The implementation is actually the same (and in fact very simple as you said), but the tests are different. In [this version](https://github.com/alejandrodob/expects/tree/not-equal-strict-comparison-support) I've added the tests in a different context, also making them very explicit. I do not like about them that they're a bit out of the line of the rest of the tests, as they are not really describing a spec, but an implementation detail maybe (by spying on the call to the `__eq__` method). On the other hand, [here](https://github.com/alejandrodob/expects/tree/not-equal-strict-comparison-support-v2) I've tried to keep the same existing tests, but instead of comparing numbers, compare instances of a class with a \"special\" `__eq__` behaviour so it fails for some special cases, thus making it easy to catch the bug for those special cases when using `not_to(equal)`.\r\n\r\nI think that this second version, despite being a bit trickier, is more in the spirit of the rest of the project tests.\r\n\r\nPlease, take a look at both and tell me what you think, if you prefer any of them or they're both crazy :)"}}