-
Notifications
You must be signed in to change notification settings - Fork 773
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
Tests: test that collect and remove have expected behaviour. #2062
base: main
Are you sure you want to change the base?
Conversation
Out of scope feature request removed. |
test/general/TestItems.py
Outdated
# Non-Advancement should not modify state. | ||
base_state = multiworld.state.prog_items.copy() | ||
multiworld.state.collect(item) | ||
self.assertEqual(base_state, multiworld.state.prog_items) |
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.
Seems like the variable base_state
could be removed and empty_prog_items
be used instead (once the bug on the line below has been fixed.)
Out of scope feature request removed.
Out of scope feature request removed. |
Yacht Dice and Tunic are doing stuff like this
to track the staleness of some custom state. This unit test would break that. It actually works out for Yacht Dice (because in Yacht Dice's case, the fake prog item is called What Tunic does is it lazily calculates and caches the accessibility of its areas by a specific metric and then marks them as "succeeded" (2), "failed" (1) or "unchecked" (0), as key-value pairs on A collect causes all "failed" areas to go back to "unchecked", but leaves "succeeded" areas as "succeeded" (cause gaining an item can never fail a previously successful check). This means that collect -> remove could leave a lot of areas as "failed" (1) that were previously "unchecked" (0). Which is correct. Information was literally gained about the accessibility of areas, that is fine to persist through the remove. |
I believe it's not, and is why CollectionState extending exists. |
# Conflicts: # test/general/test_items.py
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.
for a simple test that can catch mistakes this is perfect, code makes sense and has already caught multiple mistakes when I have used it,
That being said it is not the end all be all of testing collect/remove because any complex collect/remove that changes depending on what the current state is, will not be fully tested because state will always be empty (or fail the test) for each new item.
I don't think this is a reason not to merge as-is, but we should be aware that some issues (like HK's split cloak issues, see #1844) may not be caught with just this test
test/general/test_items.py
Outdated
multiworld.state.collect(item) | ||
self.assertEqual(base_state, multiworld.state.prog_items) | ||
|
||
multiworld.state.prog_items = empty_prog_items |
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.
per discussion in ap-core-dev, this line is setting by reference and causing errors to go unnoticed
a couple of things seem to work, that I don't have much of an opinion on which is better
- deepcopy when copying prog_items
- copying CollectionState instead and using that state's prog_items when comparing
- copy a new CollectionState for each item_name and using that state's collect() instead of copying the state back to multiworld each loop
Ftr, I was just made aware that this PR includes a test that non-progression doesn't change state Wanted to make you aware of an alternative PR that just straight up asserts this |
Opened #4468 that handles the issue I still have with the PR, the other approaches I outlined in my last comment are still valid, but I implemented the approach that made the most sense to me |
…nstead of copying it every iteration (#4468)
FYI test failures are appropriate and handled by #4433 |
What is this fixing or adding?
test that collect and remove have expected behaviour
How was this tested?
test
If this makes graphical changes, please attach screenshots.