Test natively json output
It seems that at least 50+ tests in 20+ files in a famous application using should are actually performin tests on content of JSON files. These tests can be on the presence/absence of an object (foo.bar
), or on patterns on the related values.
Several of these tests rely on a hack to fit should paradigm, and do not really test nested keys as they would like to do.
Should could provide a more convenient way for these tests. A proposed syntax (is it compatible with the proposed #34 ?):
# keys
j:foo.bar
j0:foo.bar
j12:foo.months # 'foo.months' is either an array or an object, with 12 members
# keys and values
j:foo.bar:pattern
j4:foo.months:ber # 4 members in 'foo.months' have the 'ber' pattern
And (second iteration):
j:foo.*.bar
j42:*.bar
j:foo.*.bar:pattern
j::pattern
By default, this would imply as usual that checking is done on one line (as natively exported by Python json.dumps()
). But jl:foo.bar
would be possible.
The implementation could be almost all in TestCase.test()
. The tested line/content would go through json.loads()
, then there would be new code setting self.count
.