cwacek / python-jsonschema-objects

Automatic Python binding generation from JSON Schemas
MIT License
363 stars 96 forks source link

cleanup: Remove unused test_regression_143 "validate" mocks #253

Closed EliahKagan closed 1 year ago

EliahKagan commented 1 year ago

In both test_regression_143 tests, mocks for validator.validate were created and bound to validate variables, but no assertions were made using them. The validate variables were like the validate_items variables, but for validator.validate instead of validator.validate_items, and unused, with no observable effects.

It is possible to add assertions for validate.call_count, alongside the existing validate_items.call_count assertions. I did this first, asserting the same number of call counts as in the corresponding validate_items assertions. If this is what is intended, then that could be kept, and the second commit in this PR dropped or reverted.

However, considering the effect of that change together with the code introduced in #149 (which completed #143) suggests that, unlike in the case of validator.validate_items, the current fact that validator.validate is called this number of times, and no more, does not appear to be a something these tests intend to claim and verify. I say that because:

So I added that second commit to remove the validate mocks (and their assertions, which I'd added in the first commit). validate_items is of course still mocked and its call counts asserted, as before. The tests' behavior is effectively the same as before, so this PR (if not modified further) is effectively a cleanup, even though neither of the commits in it is by itself a cleanup.

I've kept both commits (rather than squashing them into one) so the reasoning is clear in the code, and also because I think that may make it easier to modify this PR if that turns out to be helpful.