pytest-check icon indicating copy to clipboard operation
pytest-check copied to clipboard

Support f-strings in py-check custom error messages

Open GrayedFox opened this issue 3 years ago • 0 comments
trafficstars

I have a test like so (fixture handles sending requests and storing the response data):

def test_something(self):
    url = self.response.data['url']
    check.is_true(url.endswith(self.extension), f'Image quality uri for device {self.device} should end with {self.extension}')

Depending on the params used for the test, the extension and device changes. This way I can feed in different parameters and still use the same test. However the output I get is as follows:

FAILURE: Image quality uri for device android should end with .tflite
assert False
 +  where False = bool(False)
integration/tests/test_initialize.py:64 in test_initialize_returns_correct_image_uri() -> check.is_true(url.endswith(self.extension), f'Image quality uri for device {self.device} should end with {self.extension}')
------------------------------------------------------------
Failed Checks: 1

I would like the f-string to properly interpolate the string with the variables, if possible 😄

Not sure if this is a clone of #52

GrayedFox avatar Jan 19 '22 11:01 GrayedFox