shawnbrown / datatest

Tools for test driven data-wrangling and data validation.
Other
294 stars 13 forks source link

Squint objects not handled properly when used as requirements. #50

Closed shawnbrown closed 3 years ago

shawnbrown commented 4 years ago

Squint objects are not being evaluated properly by datatest.validate() function:

import datatest
import squint

# Create a Select object.
select = squint.Select([['A', 'B'], ['x', 1], ['y', 2], ['z', 3]])

# Compare data to itself--passes as expected.
datatest.validate(
    select({'A': {'B'}}),
    select({'A': {'B'}}).fetch(),  # <- Shouldn't be necessary.
)

# Compare data to itself--fails, unexpectedly.
datatest.validate(
    select({'A': {'B'}}),
    select({'A': {'B'}}),  # <- Not properly handled!
)

In the code above, the second call to datatest.validate() should pass but, instead, fails with the following message:

Traceback (most recent call last):
  File "<input>", line 3, in <module>
    select({'A': {'B'}}),  # <- Not properly handled!
  File "~/datatest-project/datatest/validation.py", line 291, in __call__
    raise err
datatest.ValidationError: does not satisfy mapping requirements (3 differences): {
    'x': [Invalid(1)],
    'y': [Invalid(2)],
    'z': [Invalid(3)],
}
shawnbrown commented 3 years ago

This bug is present in version 0.9.6 but has been fixed in 0.9.7.