EastAgile / robber.py

BDD / TDD assertion library for Python
MIT License
8 stars 1 forks source link

[f] Make eq failure message clearer #31

Closed catriuspham closed 7 years ago

catriuspham commented 7 years ago

Issue: https://github.com/EastAgile/robber.py/issues/30

Change the eq failure message format to this:

Expected type("value") to equal type("value"))

For example:

expect(123).to.be.eq('123')

Returns the message:

BadExpectation: 'Expected int("123") to equal str("123")'
catriuspham commented 7 years ago

@NhanHo @hieueastagile please take a look :)

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 99.691% when pulling 51f4fed4a669e0343ad13500b3bc68c2f7489233 on feature/clearer_eq_failure_message into 2caf3a57138b61d10c93ed1b5ec76c4259241bea on master.

hieueastagile commented 7 years ago

@catriuspham Your implementation is great, but my thought that we must have a better explanation system, so we are not just working around for this case but solve it generally and completely. We can do something like this

Expect X=123 to be equal Y='123', X is integer but Y is string.

and also for object comparision

Expect X={'key1': 'a'} to be equal Y={'key2': 'b'}. X has 'key1' but Y doesn't.

Wdyt?

catriuspham commented 7 years ago

@hieueastagile Your idea is cool, but I cannot figure out a good way to do it rather than handling each scenario separately. @NhanHo Do you have any suggestions?

hieueastagile commented 7 years ago

@catriuspham You can take a look at sure. It had kind of DeepExplaination, which is the idea that I originated from. But yes, we need to handle it quite specifically.

tklarryonline commented 7 years ago

I think for the case of type, we just need to make the message clearer like:

Expected "123" (type `int`) to equal "123" (type `str`).

So @catriuspham's approach is fine for me 😛.

catriuspham commented 7 years ago

@tklarryonline glad to see you alive!

hieueastagile commented 7 years ago

@catriuspham Ok, so please ask @oyster to merge this to master first, I will make the clearer requirements for deep explanation later.