#πŸ”’ Test in Pytest for an array (which consists of string elements)

4 messages Β· Page 1 of 1 (latest)

lyric sandal
#

Can I write a test in Pytest for an array (which consists of string elements) defined in SQLAlchemy like this

# The list of URLs of the product's images
    product_images: Mapped[list[str]] = mapped_column(
        ARRAY(item_type=String), comment="The list of image URLs for the products."
    )

The test:

def test_product_table_has_product_images_column_of__data_type(self, product:ProductClass) -> None:
        """Test if the product images column is of String data type."""
        assert isinstance(product.__table__.columns.product_images.type.item_type, String)

My tests seem to be passing though.

jaunty shardBOT
#

@lyric sandal

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

jaunty shardBOT
#

@lyric sandal

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.