mwilliamson / python-precisely

Matcher library for Python
BSD 2-Clause "Simplified" License
238 stars 11 forks source link

Question - contains_exactly expected behaviour #8

Closed danodonovan closed 6 years ago

danodonovan commented 6 years ago

I had to re-read this message a couple of times before I understood what was happening. I think the message might be clearer, but uncertain whether the current implementation is intentional.

Concerning the third part, we see These elements were in the iterable but did not match when in fact all elements are in the iterable, and would have matched had they been reached.

E           AssertionError:
E           Expected: iterable containing these 5 elements in any order:
E             * ('associates_DaG', 6)
E             * ('regulates_GrG', 5)
E             * ('inhibits_CiG', 1)
E             * ('treats_CtD', 2)
E             * ('nlptreats_CtD', 1)
E           but: was missing element:
E             * ('inhibits_CiG', 1)
E           These elements were in the iterable, but did not match:
E             * ('regulates_GrG', 5): already matched
E             * ('associates_DaG', 6): already matched
E             * ('treats_CtD', 2): was ('treats_CtD', 2)
E             * ('nlptreats_CtD', 1): was ('nlptreats_CtD', 1)

NB the list being tested contains four of the five elements, the missing element is correct.

I was expecting there to be four matched messages -something like;

E           but: was missing element:
E             * ('inhibits_CiG', 1)
E           These elements were in the iterable;
E             * ('regulates_GrG', 5): matched ('regulates_GrG', 5)
E             * ('associates_DaG', 6): matched ('associates_DaG', 6)
E             * ('treats_CtD', 2): matched ('treats_CtD', 2)
E             * ('nlptreats_CtD', 1): matched ('nlptreats_CtD', 1)
mwilliamson commented 6 years ago

The message is explaining the mismatches for that specific missing element. Some clearer text would probably be:

"These elements were in the iterable, but did not match the missing element:"

On Mon, 02 Jul 2018 02:32:44 -0700 danodonovan notifications@github.com wrote:

I had to re-read this message a couple of times before I understood what was happening. I think the message might be clearer, but uncertain whether the current implementation is intentional.

Concerning the third part, we see These elements were in the iterable but did not match when in fact all elements are in the iterable, and would have matched had they been reached.

E           AssertionError:
E           Expected: iterable containing these 5 elements in any
order: E             * ('associates_DaG', 6)
E             * ('regulates_GrG', 5)
E             * ('inhibits_CiG', 1)
E             * ('treats_CtD', 2)
E             * ('nlptreats_CtD', 1)
E           but: was missing element:
E             * ('inhibits_CiG', 1)
E           These elements were in the iterable, but did not match:
E             * ('regulates_GrG', 5): already matched
E             * ('associates_DaG', 6): already matched
E             * ('treats_CtD', 2): was ('treats_CtD', 2)
E             * ('nlptreats_CtD', 1): was ('nlptreats_CtD', 1)

NB the list being tested contains four of the five elements, the missing element is correct.

I was expecting there to be four matched messages -something like;

E           but: was missing element:
E             * ('inhibits_CiG', 1)
E           These elements were in the iterable;
E             * ('regulates_GrG', 5): matched ('regulates_GrG', 5)
E             * ('associates_DaG', 6): matched ('associates_DaG', 6)
E             * ('treats_CtD', 2): matched ('treats_CtD', 2)
E             * ('nlptreats_CtD', 1): matched ('nlptreats_CtD', 1)
mwilliamson commented 6 years ago

I've updated the error message as described above.