Skip to content

Commit

Permalink
fix(test): category_test teardown order fix.
Browse files Browse the repository at this point in the history
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:

python
Copy code
E   AttributeError: 'NoneType' object has no attribute 'title_group'

sefaria/model/schema.py:220: AttributeError
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.
  • Loading branch information
akiva10b committed Sep 30, 2024
1 parent 09c6dde commit afcc290
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sefaria/model/tests/category_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sefaria.helper.category import update_order_of_category_children
import datetime
class Test_Category_Editor(object):
@pytest.fixture(autouse=True, scope='module')
@pytest.fixture(scope='function')
def create_new_terms(self):
terms = []
for title in ["New Fake Category 1", "New Fake Category 2"]:
Expand Down

0 comments on commit afcc290

Please sign in to comment.