-
Notifications
You must be signed in to change notification settings - Fork 114
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
Make tests robust & independent #521
Conversation
Some notes here:
|
The fixes in |
On my system and on the windows-py3.12 platform here, there is this test failure in FAILED ixmp/tests/backend/test_base.py::TestCachingBackend::test_del_ts - AssertionError: assert 0 == 1
E AssertionError: assert 0 == 1
E + where 1 = len({(133743699349232, 'par', 'd'): i j value unit\n0 seattle new-york 2.5 km\n1 seattle c...a 1.8 km\n3 san-diego new-york 2.5 km\n4 san-diego chicago 1.8 km\n5 san-diego topeka 1.4 km})
E + where {(133743699349232, 'par', 'd'): i j value unit\n0 seattle new-york 2.5 km\n1 seattle c...a 1.8 km\n3 san-diego new-york 2.5 km\n4 san-diego chicago 1.8 km\n5 san-diego topeka 1.4 km} = <ixmp.backend.jdbc.JDBCBackend object at 0x79a3a1141520>._cache
ixmp/tests/backend/test_base.py:161: AssertionError In other words, these lines don't seem to garbage collect the cached value correctly. This seems related to #463 and #504, and the issue is resolved by running My system is running Python 3.12 with pandas 2.2.0 and JPype1 1.5.0. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #521 +/- ##
=====================================
Coverage 98.8% 98.8%
=====================================
Files 44 44
Lines 4813 4826 +13
=====================================
+ Hits 4756 4769 +13
Misses 57 57
|
We can answer this by first thinking about the intended behaviour of the subject/tested code:
The reason The comment points out that in certain cases, the intended behaviour doesn't work (we haven't diagnosed why). So So to extend: if |
Thanks for the explanation, so I'll revert/drop that commit and try to figure out how One other note: I've searched for other |
I'm not sure I completely agree with your analysis. The flaky function is called
In particular, the docs also say:
So the current flaky behaviour we see only reflects exactly that: I realize that this theoretically leaves part of our code untested, the part where we call In addition, the note that "all exceptions during the execution of del() methods are ignored" makes me wonder if we even need the try-clause in our |
e25e6a9
to
fb9ebba
Compare
I'm not sure why |
The tests seem to be doing okay this time around, but I'm not sure we want to keep the solution. In essence, the problem was that the |
Hm—in theory, backend.del_ts is not going to get called unless (a) there are no strong references anywhere, so TimeSeries.__del__ is triggered, or (b) the user calls it explicitly. (But since .jindex is WeakKeyDictionary, the presence (or absence) of In any case I think this is a safe change to make. Unless the user does (b), this is not going to throw away objects they are still using. I would put the added line in the reverse order, though: self.jindex.pop(ts, None)
self.gc() |
Working on #524, I noticed that the Jupyter notebook tests of macos-latest-py3.12 failed several times before eventually passing. They also failed on the first run on |
2b527b4
to
494f235
Compare
494f235
to
4a1b312
Compare
4a1b312
to
fc51651
Compare
* Split up test_close to receive only clean stdout
* Adapt expected values to new scenario names
fc51651
to
12464ed
Compare
This PR was superseded (and the work started here completed) in #543. |
Closes #512.
Analogous to iiasa/message_ix#784, this PR aims at making the ixmp tests less flaky. For now, this is largely done by giving
Scenario
s andPlatform
s test-specific names.This PR reverts the mitigation from #510. If all goes surprisingly well, this won't be a problem. Either way, it should not be a problem in the end if the intended changes are complete.
How to review
PR checklist
[ ] Add, expand, or update documentation.Just CI tests[ ] Update release notes.Just CI tests