shawnbrown / datatest

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

Squint nested-mapping queries not handled properly with non-mapping requirements. #54

Closed shawnbrown closed 3 years ago

shawnbrown commented 3 years ago

Validation is mishandled when data is a squint query-mapping and requirement is a non-mapping object.

import datatest
import squint

select = squint.Select([
    ['A', 'B'],
    ['x', 'foo'],
    ['x', 'bar'],
    ['y', 'foo'],
    ['y', 'bar'],
])

selection = select({'A': 'B'})  # <- Query returns a mapping.
datatest.validate(selection, str)  # <- Requirement is a non-mapping object.

The example above should pass but it fails with the following error:

$ python example.py
Traceback (most recent call last):
  File "example.py", line 13, in <module>
    datatest.validate(selection, str)
datatest.ValidationError: does not satisfy 'str' (2 differences): [
    Invalid(('x', <Result object (evaltype=list) at 0x7fd43beb>)),
    Invalid(('y', <Result object (evaltype=list) at 0x7fd43bed>)),
]