fix(test): category_test teardown order fix. #2055
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The error occurs during the teardown phase when the test tries to delete categories that reference terms that have already been deleted. Here's the relevant part of the error:
This suggests that library.get_term(self.sharedTitle) is returning None, and the code attempts to access term.title_group, resulting in an AttributeError.
The root cause is likely that the terms are being deleted before the categories that reference them during teardown. This can happen due to the order in which pytest tears down fixtures, especially when using scope='module' and autouse=True.
Change the scope to 'function' to ensure that it's torn down after create_new_cats.