Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Nov 22, 2024
1 parent d1091f1 commit fd64dbe
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6246,13 +6246,15 @@ def test_date_time(self) -> None:
)

def test_text_pdf(self) -> None:
with self.subTest("All params None, should fail"):
with self.assertRaises(ValueError):
self.faker.pdf(
nb_pages=None,
texts=None,
generator=TextPdfGenerator,
)
with (
self.subTest("All params None, should fail"),
self.assertRaises(ValueError),
):
self.faker.pdf(
nb_pages=None,
texts=None,
generator=TextPdfGenerator,
)

with self.subTest("Without params"):
pdf = self.faker.pdf(generator=TextPdfGenerator)
Expand Down Expand Up @@ -6331,19 +6333,23 @@ def test_image(self):
self.assertTrue(image)
self.assertIsInstance(image, bytes)
for image_format in {"bin"}:
with self.subTest(image_format=image_format):
with self.assertRaises(ValueError):
self.faker.image(image_format=image_format)
with (
self.subTest(image_format=image_format),
self.assertRaises(ValueError),
):
self.faker.image(image_format=image_format)

def test_wav(self) -> None:
wav = self.faker.wav()
self.assertTrue(wav)
self.assertIsInstance(wav, bytes)

def test_docx(self) -> None:
with self.subTest("All params None, should fail"):
with self.assertRaises(ValueError):
self.faker.docx(nb_pages=None, texts=None), # noqa
with (
self.subTest("All params None, should fail"),
self.assertRaises(ValueError),
):
self.faker.docx(nb_pages=None, texts=None), # noqa

with self.subTest("Without params"):
docx = self.faker.docx()
Expand All @@ -6357,9 +6363,11 @@ def test_docx(self) -> None:
self.assertIsInstance(docx, bytes)

def test_odt(self) -> None:
with self.subTest("All params None, should fail"):
with self.assertRaises(ValueError):
self.faker.odt(nb_pages=None, texts=None), # noqa
with (
self.subTest("All params None, should fail"),
self.assertRaises(ValueError),
):
self.faker.odt(nb_pages=None, texts=None), # noqa

with self.subTest("Without params"):
odt = self.faker.odt()
Expand Down Expand Up @@ -7023,9 +7031,11 @@ def objects(cls): # noqa: N805
instance=fill_dataclass(cls), # type: ignore
)

with self.subTest("fill_pydantic_model on dataclass"):
with self.assertRaises(ValueError):
_article = fill_pydantic_model(Article)
with (
self.subTest("fill_pydantic_model on dataclass"),
self.assertRaises(ValueError),
):
_article = fill_pydantic_model(Article)

with self.subTest("fill_pydantic_model"):
_obj = fill_pydantic_model(MockPydanticModel)
Expand Down

0 comments on commit fd64dbe

Please sign in to comment.