Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest.raises 3.5.0 does not work with Faults #559

Closed
backbord opened this issue Apr 6, 2018 · 1 comment
Closed

pytest.raises 3.5.0 does not work with Faults #559

backbord opened this issue Apr 6, 2018 · 1 comment

Comments

@backbord
Copy link

backbord commented Apr 6, 2018

Hi,

this is a FYI.

I've opened pytest issue 3372 as pytest 3.5.0 does break on code like

import pytest
from spyne.errors import RequestNotAllowed, InvalidCredentialsError

import mymodule

def test_a():
    with pytest.raises(RequestNotAllowed):
        mymodule.func_that_raises_request_not_allowed()

def test_b():
    with pytest.raises(InvalidCredentialsError):
        mymodule.func_that_raises_invalid_credentials_error()

with a traceback similar to this one

___ test_detect_replay_nonce[example_forecast.xml.gz] ___

    def test_a():
>       with pytest.raises(RequestNotAllowed):

tests/test_client.py:130: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/foobar/lib/python3.6/site-packages/_pytest/python_api.py:587: in raises
    for exc in filterfalse(isclass, always_iterable(expected_exception)):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <class 'spyne.error.RequestNotAllowed'>, item = 0

    def __getitem__(self, item):
>       return self.customize(**item)
E       TypeError: customize() argument after ** must be a mapping, not int

/foobar/lib/python3.6/site-packages/spyne/model/_base.py:179: TypeError

as spyne Faults have functions __getitem__ and __len__ and look iterable to python.

Thanks,
Tim

@backbord
Copy link
Author

backbord commented Apr 9, 2018

The issue has been resolved. The patch is expected to be published with next bug-fix release of pytest (see comment).

@backbord backbord closed this as completed Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant