-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix regression on YAML tests runner cache for tax benefit systems with reforms or extensions #825
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly optional feedback (we can add more tests to better document the current behaviour and preserve against regression) that could be left to a future PR, except that I'd prefer to see lines 40-47 in the test removed unless there's a good reason for them that I missed.
assert excinfo.value.variable_name == "unknown_variable" | ||
|
||
|
||
class reform_ab(Reform): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you find it necessary to have these lines 40-47 in the test? Deleting them, it seems that they are not missed, and that's expected since we mocked out the part that uses actual Python import and class loading… but maybe I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, sorry! I just forgot to remove them. Done.
|
||
ab_tax_benefit_system = _get_tax_benefit_system(baseline, 'ab', extensions) | ||
ba_tax_benefit_system = _get_tax_benefit_system(baseline, 'ba', extensions) | ||
assert ab_tax_benefit_system != ba_tax_benefit_system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's interesting to see it tested that way, it's not quite what I was expecting - and I can see how it adds value.
As I read this, we're testing only the caching mechanism; the test doesn't show anything about the "string -> list" conversion mechanism that provides some flexibility in how tests are written.
It would be a good idea to have one test showing the list usage and one test showing the string usage.
Similarly, for the cache it would be a good idea to show when two reform/extension specs lead to the same TaxBenefitSsytem object and when they don't.
For instance, the frozenset()
implementation implies that
_get_tax_benefit_system(baseline, ['one', 'two'], extensions)
is the same object as
_get_tax_benefit_system(baseline, ['two', 'one'], extensions)
…but do we really want that? Can we say for sure that it doesn't matter in what order we apply two different reforms? If order matters, we should replace frozenset()
by tuple()
instead.
baseline = TaxBenefitSystem() | ||
extensions = [] | ||
|
||
ab_tax_benefit_system = _get_tax_benefit_system(baseline, 'ab', extensions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest inlining the extensions value - it draws attention away from what's interesting which is the reforms parameter.
b989195
to
a1ea392
Compare
Rebased. |
assert excinfo.value.variable_name == "unknown_variable" | ||
|
||
|
||
def test_tax_benefit_systems_with_reform_cache(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these tests say all we want to say, for reforms.
It seems very likely we have a latent bug of the same kind but for extensions. If you have time, it would be good to have the same three tests but for extensions; or if you prefer we can open an issue and leave that for a later PR.
Bug fix
tools/test_runner
)