File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
styleguide_example/test_examples/tests Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -63,11 +63,17 @@ class Meta:
63
63
SchoolCourseFactory ,
64
64
school = factory .SelfAttribute ('..student.school' )
65
65
)
66
+ # The `SelfAttribute` is just an interface that uses LazyAttribute under the hood:
67
+ # school_course = factory.SubFactory(
68
+ # SchoolCourseFactory,
69
+ # school=factory.LazyAttribute(lambda course: course.factory_parent.student.school)
70
+ # )
66
71
67
72
start_date = factory .SelfAttribute ('school_course.start_date' )
68
73
end_date = factory .SelfAttribute ('school_course.end_date' )
69
74
70
75
active = True
76
+ # We'd recommend you using LazyAttribute instead of Maybe as it's more explicit
71
77
deactivated_at = factory .Maybe (
72
78
'active' ,
73
79
no_declaration = factory .LazyAttribute (lambda self : faker .date_between_dates (
@@ -86,6 +92,12 @@ def get_future_roster_start_date(roster_obj):
86
92
87
93
88
94
class FutureRosterFactory (RosterFactory ):
95
+ """
96
+ Example usage:
97
+ future_roster1 = FutureRosterFactory()
98
+ future_roster2 = FutureRosterFactory(start_after=future_roster1.end_date)
99
+ """
100
+
89
101
class Params :
90
102
start_after = None
91
103
You can’t perform that action at this time.
0 commit comments