Skip to content

Commit 8f04ac2

Browse files
committed
Squelch pytest warning
Pytest warns about an upcoming change in default behaviour for post_generation hooks: it will no longer implicitly save models again. We don't need models to be saved again after post-generation, so opt into the future behaviour now to silence this warning.
1 parent 5aee4a0 commit 8f04ac2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

django_afip/factories.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ class Meta:
155155
class ReceiptWithVatAndTaxFactory(ReceiptFactory):
156156
"""Receipt with a valid Vat and Tax, ready to validate."""
157157

158+
class Meta:
159+
model = models.Receipt
160+
skip_postgeneration_save = False # Remove on pytest >= 10.0
161+
158162
point_of_sales = LazyFunction(lambda: models.PointOfSales.objects.first()) # type: ignore[assignment]
159163
client_vat_condition = SubFactory(ClientVatConditionFactory)
160164

@@ -177,6 +181,10 @@ class ReceiptFCEAWithVatAndTaxFactory(ReceiptWithVatAndTaxFactory):
177181
class ReceiptFCEAWithVatTaxAndOptionalsFactory(ReceiptFCEAWithVatAndTaxFactory):
178182
"""Receipt FCEA with a valid Vat, Tax and Optionals, ready to validate."""
179183

184+
class Meta:
185+
model = models.Receipt
186+
skip_postgeneration_save = False # Remove on pytest >= 10.0
187+
180188
total_amount = 13_000_000
181189
net_untaxed = 0
182190
net_taxed = 10_000_000
@@ -204,6 +212,10 @@ def post(obj: models.Receipt, create: bool, extracted: None, **kwargs) -> None:
204212
class ReceiptWithInconsistentVatAndTaxFactory(ReceiptWithVatAndTaxFactory):
205213
"""Receipt with a valid Vat and Tax, ready to validate."""
206214

215+
class Meta:
216+
model = models.Receipt
217+
skip_postgeneration_save = False # Remove on pytest >= 10.0
218+
207219
document_type = SubFactory(DocumentTypeFactory, code=80)
208220

209221
@post_generation
@@ -215,6 +227,10 @@ def post(obj: models.Receipt, create: bool, extracted: None, **kwargs) -> None:
215227
class ReceiptWithApprovedValidation(ReceiptFactory):
216228
"""Receipt with fake (e.g.: not live) approved validation."""
217229

230+
class Meta:
231+
model = models.Receipt
232+
skip_postgeneration_save = False # Remove on pytest >= 10.0
233+
218234
receipt_number = Sequence(lambda n: n + 1)
219235

220236
@post_generation
@@ -248,6 +264,12 @@ class Meta:
248264

249265

250266
class ReceiptPDFWithFileFactory(ReceiptPDFFactory):
267+
"""ReceiptPDF with an actual PDF file generated."""
268+
269+
class Meta:
270+
model = models.ReceiptPDF
271+
skip_postgeneration_save = False # Remove on pytest >= 10.0
272+
251273
receipt = SubFactory(ReceiptWithApprovedValidation)
252274

253275
@post_generation
@@ -335,6 +357,10 @@ class Meta:
335357
class ReceiptWithClientVatConditionFactory(ReceiptFactory):
336358
"""Receipt with a valid Client VAT Condition, ready to validate."""
337359

360+
class Meta:
361+
model = models.Receipt
362+
skip_postgeneration_save = False # Remove on pytest >= 10.0
363+
338364
client_vat_condition = SubFactory(ClientVatConditionFactory)
339365

340366
@post_generation

0 commit comments

Comments
 (0)