Fix "message" parameter of pytest.raises

Removed in version 5.0 of pytest
https://docs.pytest.org/en/7.0.x/deprecations.html#message-parameter-of-pytest-raises
This commit is contained in:
Santiago L 2022-02-08 14:48:54 +01:00
parent 8c8323308b
commit 311369691f
2 changed files with 37 additions and 34 deletions

View File

@ -75,14 +75,14 @@ def test_erase_basic():
def test_validate_device_data_storage(): def test_validate_device_data_storage():
"""Checks the validation for data-storage-only actions works.""" """Checks the validation for data-storage-only actions works."""
# We can't set a GraphicCard # We can't set a GraphicCard
with pytest.raises(TypeError, with pytest.raises(TypeError):
message='EraseBasic.device must be a DataStorage '
'but you passed <GraphicCard None model=\'foo-bar\' S/N=\'foo\'>'):
models.EraseBasic( models.EraseBasic(
device=GraphicCard(serial_number='foo', manufacturer='bar', model='foo-bar'), device=GraphicCard(serial_number='foo', manufacturer='bar', model='foo-bar'),
clean_with_zeros=True, clean_with_zeros=True,
**conftest.T **conftest.T
) )
pytest.fail('EraseBasic.device must be a DataStorage '
'but you passed <GraphicCard None model=\'foo-bar\' S/N=\'foo\'>')
@pytest.mark.mvp @pytest.mark.mvp

View File

@ -24,11 +24,14 @@ def test_authenticate_error(app: Devicehub):
MESSAGE = 'Provide a suitable token.' MESSAGE = 'Provide a suitable token.'
create_user() create_user()
# Token doesn't exist # Token doesn't exist
with pytest.raises(Unauthorized, message=MESSAGE): with pytest.raises(Unauthorized):
app.auth.authenticate(token=str(uuid4())) app.auth.authenticate(token=str(uuid4()))
pytest.fail(MESSAGE)
# Wrong token format # Wrong token format
with pytest.raises(Unauthorized, message=MESSAGE): with pytest.raises(Unauthorized):
app.auth.authenticate(token='this is a wrong uuid') app.auth.authenticate(token='this is a wrong uuid')
pytest.fail(MESSAGE)
@pytest.mark.mvp @pytest.mark.mvp