Skip to content

Commit 3443dce

Browse files
committed
Refactor fixture loading to use dictionary instead of function.
Replaced the `fixtures()` function with a dictionary object for improved readability and simplicity. Updated the related call to access the dictionary directly, eliminating unnecessary function wrapping.
1 parent 249dd16 commit 3443dce

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/alembic/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def _add_fixture_data_to_session(
203203
Returns:
204204
None
205205
"""
206-
session.add_all(fixture_module.fixtures().get(bind_name, []))
206+
session.add_all(fixture_module.fixtures.get(bind_name, []))
207207
session.add(
208208
fixture_migration_models[bind_name](
209209
bind=bind_name,

src/alembic/fixtures/books_example.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
44
"BIND_NAME": "LIST_OF_FACTORIES"
55
"""
6-
7-
from typing import Dict, List
8-
96
from factory import Factory
107

118
from domains.books._models import BookModel
129

1310

14-
def fixtures() -> Dict[str, List]:
15-
class BookFactory(Factory):
16-
class Meta:
17-
model = BookModel
11+
class BookFactory(Factory):
12+
class Meta:
13+
model = BookModel
14+
1815

19-
return {
20-
"default": [
21-
BookFactory(
22-
title="The Shining",
23-
author_name="Stephen King",
24-
),
25-
],
26-
}
16+
fixtures = {
17+
"default": [
18+
BookFactory(
19+
title="The Shining",
20+
author_name="Stephen King",
21+
),
22+
],
23+
}

0 commit comments

Comments
 (0)