Skip to content

0.16.5: pytest is failing in few units #525

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

Closed
kloczek opened this issue Mar 1, 2023 · 3 comments
Closed

0.16.5: pytest is failing in few units #525

kloczek opened this issue Mar 1, 2023 · 3 comments

Comments

@kloczek
Copy link

kloczek commented Mar 1, 2023

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix>
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-openapi-core-0.16.5-3.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-openapi-core-0.16.5-3.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/openapi-core-0.16.5, configfile: pyproject.toml
plugins: anyio-3.6.2, flake8-1.1.1
collected 742 items

tests/integration/contrib/django/test_django_project.py Bad Request: /v1/pets
..Bad Request: /v1/pets
.Bad Request: /v1/pets
.Unsupported Media Type: /v1/pets
.Bad Request: /v1/pets
...Invalid HTTP_HOST header: 'testserver'. You may need to add 'testserver' to ALLOWED_HOSTS.
Bad Request: /v1/pets/12
.Forbidden: /v1/pets/12
.Method Not Allowed: /v1/pets/12
...
tests/integration/contrib/falcon/test_falcon_project.py .............
tests/integration/contrib/flask/test_flask_decorator.py ......
tests/integration/contrib/flask/test_flask_validator.py .
tests/integration/contrib/flask/test_flask_views.py .......
tests/integration/contrib/requests/test_requests_validation.py ...
tests/integration/contrib/starlette/test_starlette_validation.py ..
tests/integration/contrib/werkzeug/test_werkzeug_validation.py ...
tests/integration/schema/test_empty.py .
tests/integration/schema/test_link_spec.py ....
tests/integration/schema/test_path_params.py ..
tests/integration/schema/test_spec.py ..
tests/integration/validation/test_minimal.py ............................................................
tests/integration/validation/test_petstore.py .....................................
tests/integration/validation/test_read_only_write_only.py ....
tests/integration/validation/test_security_override.py .....
tests/integration/validation/test_validators.py ............................
tests/unit/test_util.py .................
tests/unit/casting/test_schema_casters.py ....
tests/unit/contrib/django/test_django.py ......
tests/unit/contrib/flask/test_flask_requests.py ...
tests/unit/contrib/flask/test_flask_responses.py .
tests/unit/contrib/requests/test_requests_requests.py ...
tests/unit/contrib/requests/test_requests_responses.py .
tests/unit/deserializing/test_media_types_deserializers.py .........
tests/unit/deserializing/test_parameters_deserializers.py ...
tests/unit/extensions/test_factories.py ..
tests/unit/schema/test_schema_parameters.py .....................................................................................................................................................
tests/unit/security/test_providers.py .........
tests/unit/templating/test_media_types_finders.py ....
tests/unit/templating/test_paths_finders.py X..x..x...........X..x..x...........
tests/unit/templating/test_responses_finders.py ...
tests/unit/templating/test_templating_util.py ..
tests/unit/unmarshalling/test_unmarshal.py ....................................................................x.........................
tests/unit/unmarshalling/test_validate.py .........................................................................................F.........F.......F......FFFF...................................................................................
tests/unit/validation/test_request_shortcuts.py ..
tests/unit/validation/test_response_shortcuts.py ..

========================================================================================= FAILURES ==========================================================================================
_________________________________________________________________ TestSchemaValidate.test_string_format_date_invalid[true] __________________________________________________________________

self = <test_validate.TestSchemaValidate object at 0x7fdf7b9b2070>, value = b'true'
validator_factory = <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf783ea310>

    @pytest.mark.parametrize(
        "value",
        [
            b"true",
            "test",
            False,
            1,
            3.14,
            [1, 3],
            datetime.datetime(1989, 1, 2),
        ],
    )
    def test_string_format_date_invalid(self, value, validator_factory):
        schema = {
            "type": "string",
            "format": "date",
        }
        spec = Spec.from_dict(schema)

        with pytest.raises(InvalidSchemaValue):
>           validator_factory(spec).validate(value)
E           Failed: DID NOT RAISE <class 'openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue'>

schema     = {'format': 'date', 'type': 'string'}
self       = <test_validate.TestSchemaValidate object at 0x7fdf7b9b2070>
spec       = Spec('')
validator_factory = <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf783ea310>
value      = b'true'

tests/unit/unmarshalling/test_validate.py:404: Failed
_________________________________________________________________ TestSchemaValidate.test_string_format_uuid_invalid[true0] _________________________________________________________________

self = <test_validate.TestSchemaValidate object at 0x7fdf7b9b2700>, value = b'true'
validator_factory = <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf783eaf70>

    @pytest.mark.parametrize(
        "value",
        [
            b"true",
            "true",
            False,
            1,
            3.14,
            [1, 3],
            datetime.date(2018, 1, 2),
            datetime.datetime(2018, 1, 2, 23, 59, 59),
        ],
    )
    def test_string_format_uuid_invalid(self, value, validator_factory):
        schema = {
            "type": "string",
            "format": "uuid",
        }
        spec = Spec.from_dict(schema)

        with pytest.raises(InvalidSchemaValue):
>           validator_factory(spec).validate(value)
E           Failed: DID NOT RAISE <class 'openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue'>

schema     = {'format': 'uuid', 'type': 'string'}
self       = <test_validate.TestSchemaValidate object at 0x7fdf7b9b2700>
spec       = Spec('')
validator_factory = <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf783eaf70>
value      = b'true'

tests/unit/unmarshalling/test_validate.py:462: Failed
_______________________________________________________________ TestSchemaValidate.test_string_format_datetime_invalid[true0] _______________________________________________________________

self = <test_validate.TestSchemaValidate object at 0x7fdf7b9b2c70>, value = b'true'
validator_factory = <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf783ea790>

    @pytest.mark.parametrize(
        "value",
        [
            b"true",
            "true",
            False,
            1,
            3.14,
            [1, 3],
            "1989-01-02",
        ],
    )
    def test_string_format_datetime_invalid(self, value, validator_factory):
        schema = {
            "type": "string",
            "format": "date-time",
        }
        spec = Spec.from_dict(schema)

        with pytest.raises(InvalidSchemaValue):
>           validator_factory(spec).validate(value)
E           Failed: DID NOT RAISE <class 'openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue'>

schema     = {'format': 'date-time', 'type': 'string'}
self       = <test_validate.TestSchemaValidate object at 0x7fdf7b9b2c70>
spec       = Spec('')
validator_factory = <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf783ea790>
value      = b'true'

tests/unit/unmarshalling/test_validate.py:484: Failed
____________________________________________________ TestSchemaValidate.test_string_format_datetime_strict_rfc3339[1989-01-02T00:00:00Z] ____________________________________________________

args = (<test_validate.TestSchemaValidate object at 0x7fdf7b842190>,)
keywargs = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c4c0>, 'value': '1989-01-02T00:00:00Z'}

    @wraps(func)
    def patched(*args, **keywargs):
>       with self.decoration_helper(patched,
                                    args,
                                    keywargs) as (newargs, newkeywargs):

args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b842190>,)
func       = <function TestSchemaValidate.test_string_format_datetime_strict_rfc3339 at 0x7fdf7ba160d0>
keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c4c0>, 'value': '1989-01-02T00:00:00Z'}
patched    = <function TestSchemaValidate.test_string_format_datetime_strict_rfc3339 at 0x7fdf7ba16160>
self       = <unittest.mock._patch object at 0x7fdf7b809640>

/usr/lib64/python3.8/unittest/mock.py:1322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/contextlib.py:113: in __enter__
    return next(self.gen)
        self       = <contextlib._GeneratorContextManager object at 0x7fdf784b4550>
/usr/lib64/python3.8/unittest/mock.py:1304: in decoration_helper
    arg = exit_stack.enter_context(patching)
        args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b842190>,)
        exit_stack = <contextlib.ExitStack object at 0x7fdf784b4d90>
        extra_args = []
        keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c4c0>, 'value': '1989-01-02T00:00:00Z'}
        patched    = <function TestSchemaValidate.test_string_format_datetime_strict_rfc3339 at 0x7fdf7ba16160>
        patching   = <unittest.mock._patch object at 0x7fdf7b809640>
        self       = <unittest.mock._patch object at 0x7fdf7b809640>
/usr/lib64/python3.8/contextlib.py:425: in enter_context
    result = _cm_type.__enter__(cm)
        _cm_type   = <class 'unittest.mock._patch'>
        _exit      = <function _patch.__exit__ at 0x7fdf7c1f51f0>
        cm         = <unittest.mock._patch object at 0x7fdf7b809640>
        self       = <contextlib.ExitStack object at 0x7fdf784b4d90>
/usr/lib64/python3.8/unittest/mock.py:1393: in __enter__
    original, local = self.get_original()
        autospec   = None
        kwargs     = {}
        new        = False
        new_callable = None
        self       = <unittest.mock._patch object at 0x7fdf7b809640>
        spec       = None
        spec_set   = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.mock._patch object at 0x7fdf7b809640>

    def get_original(self):
        target = self.getter()
        name = self.attribute

        original = DEFAULT
        local = False

        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True

        if name in _builtins and isinstance(target, ModuleType):
            self.create = True

        if not self.create and original is DEFAULT:
>           raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
E           AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'

local      = False
name       = 'DATETIME_HAS_ISODATE'
original   = sentinel.DEFAULT
self       = <unittest.mock._patch object at 0x7fdf7b809640>
target     = <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'>

/usr/lib64/python3.8/unittest/mock.py:1366: AttributeError
____________________________________________________ TestSchemaValidate.test_string_format_datetime_strict_rfc3339[2018-01-02T23:59:59Z] ____________________________________________________

args = (<test_validate.TestSchemaValidate object at 0x7fdf7b842220>,)
keywargs = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c8b0>, 'value': '2018-01-02T23:59:59Z'}

    @wraps(func)
    def patched(*args, **keywargs):
>       with self.decoration_helper(patched,
                                    args,
                                    keywargs) as (newargs, newkeywargs):

args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b842220>,)
func       = <function TestSchemaValidate.test_string_format_datetime_strict_rfc3339 at 0x7fdf7ba160d0>
keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c8b0>, 'value': '2018-01-02T23:59:59Z'}
patched    = <function TestSchemaValidate.test_string_format_datetime_strict_rfc3339 at 0x7fdf7ba16160>
self       = <unittest.mock._patch object at 0x7fdf7b809640>

/usr/lib64/python3.8/unittest/mock.py:1322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/contextlib.py:113: in __enter__
    return next(self.gen)
        self       = <contextlib._GeneratorContextManager object at 0x7fdf7814ec10>
/usr/lib64/python3.8/unittest/mock.py:1304: in decoration_helper
    arg = exit_stack.enter_context(patching)
        args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b842220>,)
        exit_stack = <contextlib.ExitStack object at 0x7fdf7814ec40>
        extra_args = []
        keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c8b0>, 'value': '2018-01-02T23:59:59Z'}
        patched    = <function TestSchemaValidate.test_string_format_datetime_strict_rfc3339 at 0x7fdf7ba16160>
        patching   = <unittest.mock._patch object at 0x7fdf7b809640>
        self       = <unittest.mock._patch object at 0x7fdf7b809640>
/usr/lib64/python3.8/contextlib.py:425: in enter_context
    result = _cm_type.__enter__(cm)
        _cm_type   = <class 'unittest.mock._patch'>
        _exit      = <function _patch.__exit__ at 0x7fdf7c1f51f0>
        cm         = <unittest.mock._patch object at 0x7fdf7b809640>
        self       = <contextlib.ExitStack object at 0x7fdf7814ec40>
/usr/lib64/python3.8/unittest/mock.py:1393: in __enter__
    original, local = self.get_original()
        autospec   = None
        kwargs     = {}
        new        = False
        new_callable = None
        self       = <unittest.mock._patch object at 0x7fdf7b809640>
        spec       = None
        spec_set   = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.mock._patch object at 0x7fdf7b809640>

    def get_original(self):
        target = self.getter()
        name = self.attribute

        original = DEFAULT
        local = False

        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True

        if name in _builtins and isinstance(target, ModuleType):
            self.create = True

        if not self.create and original is DEFAULT:
>           raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
E           AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'

local      = False
name       = 'DATETIME_HAS_ISODATE'
original   = sentinel.DEFAULT
self       = <unittest.mock._patch object at 0x7fdf7b809640>
target     = <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'>

/usr/lib64/python3.8/unittest/mock.py:1366: AttributeError
_______________________________________________________ TestSchemaValidate.test_string_format_datetime_isodate[1989-01-02T00:00:00Z] ________________________________________________________

args = (<test_validate.TestSchemaValidate object at 0x7fdf7b8423d0>,)
keywargs = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c820>, 'value': '1989-01-02T00:00:00Z'}

    @wraps(func)
    def patched(*args, **keywargs):
>       with self.decoration_helper(patched,
                                    args,
                                    keywargs) as (newargs, newkeywargs):

args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b8423d0>,)
func       = <function TestSchemaValidate.test_string_format_datetime_isodate at 0x7fdf7ba16310>
keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c820>, 'value': '1989-01-02T00:00:00Z'}
patched    = <function TestSchemaValidate.test_string_format_datetime_isodate at 0x7fdf7ba163a0>
self       = <unittest.mock._patch object at 0x7fdf7b9aa460>

/usr/lib64/python3.8/unittest/mock.py:1322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/contextlib.py:113: in __enter__
    return next(self.gen)
        self       = <contextlib._GeneratorContextManager object at 0x7fdf7810c100>
/usr/lib64/python3.8/unittest/mock.py:1304: in decoration_helper
    arg = exit_stack.enter_context(patching)
        args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b8423d0>,)
        exit_stack = <contextlib.ExitStack object at 0x7fdf7810c940>
        extra_args = []
        keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c820>, 'value': '1989-01-02T00:00:00Z'}
        patched    = <function TestSchemaValidate.test_string_format_datetime_isodate at 0x7fdf7ba163a0>
        patching   = <unittest.mock._patch object at 0x7fdf7b9aa460>
        self       = <unittest.mock._patch object at 0x7fdf7b9aa460>
/usr/lib64/python3.8/contextlib.py:425: in enter_context
    result = _cm_type.__enter__(cm)
        _cm_type   = <class 'unittest.mock._patch'>
        _exit      = <function _patch.__exit__ at 0x7fdf7c1f51f0>
        cm         = <unittest.mock._patch object at 0x7fdf7b9aa460>
        self       = <contextlib.ExitStack object at 0x7fdf7810c940>
/usr/lib64/python3.8/unittest/mock.py:1393: in __enter__
    original, local = self.get_original()
        autospec   = None
        kwargs     = {}
        new        = True
        new_callable = None
        self       = <unittest.mock._patch object at 0x7fdf7b9aa460>
        spec       = None
        spec_set   = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.mock._patch object at 0x7fdf7b9aa460>

    def get_original(self):
        target = self.getter()
        name = self.attribute

        original = DEFAULT
        local = False

        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True

        if name in _builtins and isinstance(target, ModuleType):
            self.create = True

        if not self.create and original is DEFAULT:
>           raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
E           AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'

local      = False
name       = 'DATETIME_HAS_ISODATE'
original   = sentinel.DEFAULT
self       = <unittest.mock._patch object at 0x7fdf7b9aa460>
target     = <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'>

/usr/lib64/python3.8/unittest/mock.py:1366: AttributeError
_______________________________________________________ TestSchemaValidate.test_string_format_datetime_isodate[2018-01-02T23:59:59Z] ________________________________________________________

args = (<test_validate.TestSchemaValidate object at 0x7fdf7b842460>,)
keywargs = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c310>, 'value': '2018-01-02T23:59:59Z'}

    @wraps(func)
    def patched(*args, **keywargs):
>       with self.decoration_helper(patched,
                                    args,
                                    keywargs) as (newargs, newkeywargs):

args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b842460>,)
func       = <function TestSchemaValidate.test_string_format_datetime_isodate at 0x7fdf7ba16310>
keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c310>, 'value': '2018-01-02T23:59:59Z'}
patched    = <function TestSchemaValidate.test_string_format_datetime_isodate at 0x7fdf7ba163a0>
self       = <unittest.mock._patch object at 0x7fdf7b9aa460>

/usr/lib64/python3.8/unittest/mock.py:1322:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/contextlib.py:113: in __enter__
    return next(self.gen)
        self       = <contextlib._GeneratorContextManager object at 0x7fdf781a6fa0>
/usr/lib64/python3.8/unittest/mock.py:1304: in decoration_helper
    arg = exit_stack.enter_context(patching)
        args       = (<test_validate.TestSchemaValidate object at 0x7fdf7b842460>,)
        exit_stack = <contextlib.ExitStack object at 0x7fdf781a6f40>
        extra_args = []
        keywargs   = {'validator_factory': <function TestSchemaValidate.validator_factory.<locals>.create_validator at 0x7fdf7831c310>, 'value': '2018-01-02T23:59:59Z'}
        patched    = <function TestSchemaValidate.test_string_format_datetime_isodate at 0x7fdf7ba163a0>
        patching   = <unittest.mock._patch object at 0x7fdf7b9aa460>
        self       = <unittest.mock._patch object at 0x7fdf7b9aa460>
/usr/lib64/python3.8/contextlib.py:425: in enter_context
    result = _cm_type.__enter__(cm)
        _cm_type   = <class 'unittest.mock._patch'>
        _exit      = <function _patch.__exit__ at 0x7fdf7c1f51f0>
        cm         = <unittest.mock._patch object at 0x7fdf7b9aa460>
        self       = <contextlib.ExitStack object at 0x7fdf781a6f40>
/usr/lib64/python3.8/unittest/mock.py:1393: in __enter__
    original, local = self.get_original()
        autospec   = None
        kwargs     = {}
        new        = True
        new_callable = None
        self       = <unittest.mock._patch object at 0x7fdf7b9aa460>
        spec       = None
        spec_set   = None
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.mock._patch object at 0x7fdf7b9aa460>

    def get_original(self):
        target = self.getter()
        name = self.attribute

        original = DEFAULT
        local = False

        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True

        if name in _builtins and isinstance(target, ModuleType):
            self.create = True

        if not self.create and original is DEFAULT:
>           raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
E           AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'

local      = False
name       = 'DATETIME_HAS_ISODATE'
original   = sentinel.DEFAULT
self       = <unittest.mock._patch object at 0x7fdf7b9aa460>
target     = <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'>

/usr/lib64/python3.8/unittest/mock.py:1366: AttributeError
===================================================================================== warnings summary ======================================================================================
tests/integration/contrib/django/test_django_project.py::TestPetListView::test_get_no_required_param
  /usr/lib/python3.8/site-packages/django/conf/__init__.py:229: RemovedInDjango50Warning: The USE_L10N setting is deprecated. Starting with Django 5.0, localized formatting of data will always be enabled. For example Django will display numbers and dates using the format of the current locale.
    warnings.warn(USE_L10N_DEPRECATED_MSG, RemovedInDjango50Warning)

tests/integration/contrib/django/test_django_project.py: 96 warnings
tests/integration/contrib/falcon/test_falcon_project.py: 78 warnings
tests/integration/contrib/flask/test_flask_decorator.py: 2 warnings
tests/integration/contrib/flask/test_flask_validator.py: 5 warnings
tests/integration/contrib/flask/test_flask_views.py: 3 warnings
tests/integration/contrib/requests/test_requests_validation.py: 10 warnings
tests/integration/contrib/starlette/test_starlette_validation.py: 5 warnings
tests/integration/contrib/werkzeug/test_werkzeug_validation.py: 10 warnings
tests/integration/validation/test_petstore.py: 146 warnings
tests/integration/validation/test_read_only_write_only.py: 5 warnings
tests/integration/validation/test_security_override.py: 3 warnings
tests/integration/validation/test_validators.py: 51 warnings
tests/unit/unmarshalling/test_unmarshal.py: 4 warnings
tests/unit/unmarshalling/test_validate.py: 197 warnings
  /usr/lib/python3.8/site-packages/openapi_schema_validator/validators.py:120: DeprecationWarning: write property is deprecated. Use OAS30WriteValidator instead.
    warnings.warn(

tests/integration/contrib/django/test_django_project.py: 61 warnings
tests/integration/contrib/falcon/test_falcon_project.py: 61 warnings
tests/integration/contrib/flask/test_flask_decorator.py: 5 warnings
tests/integration/contrib/flask/test_flask_views.py: 8 warnings
tests/integration/contrib/requests/test_requests_validation.py: 4 warnings
tests/integration/contrib/starlette/test_starlette_validation.py: 4 warnings
tests/integration/contrib/werkzeug/test_werkzeug_validation.py: 4 warnings
tests/integration/validation/test_petstore.py: 161 warnings
tests/integration/validation/test_read_only_write_only.py: 5 warnings
tests/integration/validation/test_validators.py: 20 warnings
tests/unit/unmarshalling/test_unmarshal.py: 25 warnings
  /usr/lib/python3.8/site-packages/openapi_schema_validator/validators.py:113: DeprecationWarning: read property is deprecated. Use OAS30ReadValidator instead.
    warnings.warn(

tests/integration/contrib/requests/test_requests_validation.py::TestRequestsOpenAPIValidation::test_response_validator_path_pattern
  /usr/lib/python3.8/site-packages/responses/__init__.py:421: DeprecationWarning: Argument 'match_querystring' is deprecated. Use 'responses.matchers.query_param_matcher' or 'responses.matchers.query_string_matcher'
    warn(

tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerUnmarshal::test_schema_custom_format_invalid
tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerCall::test_string_format_custom
tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerCall::test_string_format_custom_value_error
  /home/tkloczko/rpmbuild/BUILDROOT/python-openapi-core-0.16.5-3.fc35.x86_64/usr/lib/python3.8/site-packages/openapi_core/unmarshalling/schemas/formatters.py:28: DeprecationWarning: Unmarshal method is deprecated. Rename unmarshal method to format instead.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
-------------------------------------------------- generated xml file: /home/tkloczko/rpmbuild/BUILD/openapi-core-0.16.5/reports/junit.xml --------------------------------------------------
================================================================================== short test summary info ==================================================================================
XFAIL tests/unit/templating/test_paths_finders.py::TestOperationSimpleServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/templating/test_paths_finders.py::TestPathSimpleServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/templating/test_paths_finders.py::TestOperationVariableServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/templating/test_paths_finders.py::TestPathVariableServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerCall::test_null_not_supported
XPASS tests/unit/templating/test_paths_finders.py::TestSpecSimpleServerServerNotFound::test_raises returns default server
XPASS tests/unit/templating/test_paths_finders.py::TestSpecVariableServerServerNotFound::test_raises returns default server
FAILED tests/unit/unmarshalling/test_validate.py::TestSchemaValidate::test_string_format_date_invalid[true] - Failed: DID NOT RAISE <class 'openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue'>
FAILED tests/unit/unmarshalling/test_validate.py::TestSchemaValidate::test_string_format_uuid_invalid[true0] - Failed: DID NOT RAISE <class 'openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue'>
FAILED tests/unit/unmarshalling/test_validate.py::TestSchemaValidate::test_string_format_datetime_invalid[true0] - Failed: DID NOT RAISE <class 'openapi_core.unmarshalling.schemas.exceptions.InvalidSchemaValue'>
FAILED tests/unit/unmarshalling/test_validate.py::TestSchemaValidate::test_string_format_datetime_strict_rfc3339[1989-01-02T00:00:00Z] - AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'
FAILED tests/unit/unmarshalling/test_validate.py::TestSchemaValidate::test_string_format_datetime_strict_rfc3339[2018-01-02T23:59:59Z] - AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'
FAILED tests/unit/unmarshalling/test_validate.py::TestSchemaValidate::test_string_format_datetime_isodate[1989-01-02T00:00:00Z] - AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'
FAILED tests/unit/unmarshalling/test_validate.py::TestSchemaValidate::test_string_format_datetime_isodate[2018-01-02T23:59:59Z] - AttributeError: <module 'openapi_schema_validator._format' from '/usr/lib/python3.8/site-packages/openapi_schema_validator/_format.py'> does not have the attribute 'DATETIME_HAS_ISODATE'
============================================================= 7 failed, 728 passed, 5 xfailed, 2 xpassed, 978 warnings in 5.12s =============================================================

Here is list of installed modules in build env

Package                       Version
----------------------------- -----------------
alabaster                     0.7.13
anyio                         3.6.2
asgiref                       3.4.1
attrs                         22.2.0
Babel                         2.12.1
backports.zoneinfo            0.2.1
build                         0.9.0
charset-normalizer            3.0.1
click                         8.1.3
distro                        1.8.0
Django                        4.0.4
djangorestframework           3.14.0
docutils                      0.19
exceptiongroup                1.0.0
falcon                        3.1.1
flake8                        5.0.4
Flask                         2.2.2
gpg                           1.18.0-unknown
idna                          3.4
imagesize                     1.4.1
importlib-metadata            6.0.0
importlib-resources           5.12.0
iniconfig                     2.0.0
isodate                       0.6.1
itsdangerous                  2.1.2
Jinja2                        3.1.2
jsonschema                    4.17.3
jsonschema-spec               0.1.3
lazy-object-proxy             1.9.0
libcomps                      0.1.19
MarkupSafe                    2.1.2
mccabe                        0.7.0
more-itertools                9.1.0
openapi-schema-validator      0.4.3
openapi-spec-validator        0.5.5
packaging                     23.0
parse                         1.19.0
pathable                      0.4.3
pep517                        0.13.0
pip                           22.3.1
pkgutil_resolve_name          1.3.10
pluggy                        1.0.0
poetry-core                   1.5.1
pycodestyle                   2.9.1
pyflakes                      2.5.0
Pygments                      2.14.0
pyrsistent                    0.19.3
pytest                        7.2.1
pytest-flake8                 1.1.1
python-dateutil               2.8.2
pytz                          2022.4
PyYAML                        6.0
requests                      2.28.2
responses                     0.22.0
rfc3339-validator             0.1.4
rpm                           4.17.0
six                           1.16.0
sniffio                       1.2.0
snowballstemmer               2.2.0
Sphinx                        6.1.3
sphinxcontrib-applehelp       1.0.4
sphinxcontrib-devhelp         1.0.2.dev20230202
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1.dev20230128
sphinxcontrib-qthelp          1.0.3.dev20230128
sphinxcontrib-serializinghtml 1.1.5
sqlparse                      0.4.2
starlette                     0.20.4
strict-rfc3339                0.7
tomli                         2.0.1
tomli_w                       1.0.0
typing_extensions             4.4.0
urllib3                       1.26.12
WebOb                         1.8.7
Werkzeug                      2.2.2
wheel                         0.38.4
zipp                          3.15.0
@p1c2u
Copy link
Collaborator

p1c2u commented Mar 1, 2023

@kloczek thank you for this report. I think this is because of backward incompatibility introduced here
https://github.com/python-openapi/openapi-schema-validator/releases/tag/0.4.2
Worth to release a fix for 0.16.x branch that limits the dependency to version 0.4.1 at most or make the tests compatible with openapi-schema-validator 0.4.2.

@p1c2u
Copy link
Collaborator

p1c2u commented Mar 2, 2023

Version 0.16.6 released with the fix hence closing.

@p1c2u p1c2u closed this as completed Mar 2, 2023
@kloczek
Copy link
Author

kloczek commented Mar 2, 2023

Just tested 0.16.6 and test site passes without errors/fauls.
I see some warnings which probably one is related to openapi-core code
Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-openapi-core-0.16.6-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-openapi-core-0.16.6-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/openapi-core-0.16.6, configfile: pyproject.toml
plugins: anyio-3.6.2, flake8-1.1.1
collected 735 items

tests/integration/contrib/django/test_django_project.py Bad Request: /v1/pets
..Bad Request: /v1/pets
.Bad Request: /v1/pets
.Unsupported Media Type: /v1/pets
.Bad Request: /v1/pets
...Invalid HTTP_HOST header: 'testserver'. You may need to add 'testserver' to ALLOWED_HOSTS.
Bad Request: /v1/pets/12
.Forbidden: /v1/pets/12
.Method Not Allowed: /v1/pets/12
...
tests/integration/contrib/falcon/test_falcon_project.py .............
tests/integration/contrib/flask/test_flask_decorator.py ......
tests/integration/contrib/flask/test_flask_validator.py .
tests/integration/contrib/flask/test_flask_views.py .......
tests/integration/contrib/requests/test_requests_validation.py ...
tests/integration/contrib/starlette/test_starlette_validation.py ..
tests/integration/contrib/werkzeug/test_werkzeug_validation.py ...
tests/integration/schema/test_empty.py .
tests/integration/schema/test_link_spec.py ....
tests/integration/schema/test_path_params.py ..
tests/integration/schema/test_spec.py ..
tests/integration/validation/test_minimal.py ............................................................
tests/integration/validation/test_petstore.py .....................................
tests/integration/validation/test_read_only_write_only.py ....
tests/integration/validation/test_security_override.py .....
tests/integration/validation/test_validators.py ............................
tests/unit/test_util.py .................
tests/unit/casting/test_schema_casters.py ....
tests/unit/contrib/django/test_django.py ......
tests/unit/contrib/flask/test_flask_requests.py ...
tests/unit/contrib/flask/test_flask_responses.py .
tests/unit/contrib/requests/test_requests_requests.py ...
tests/unit/contrib/requests/test_requests_responses.py .
tests/unit/deserializing/test_media_types_deserializers.py .........
tests/unit/deserializing/test_parameters_deserializers.py ...
tests/unit/extensions/test_factories.py ..
tests/unit/schema/test_schema_parameters.py .....................................................................................................................................................
tests/unit/security/test_providers.py .........
tests/unit/templating/test_media_types_finders.py ....
tests/unit/templating/test_paths_finders.py X..x..x...........X..x..x...........
tests/unit/templating/test_responses_finders.py ...
tests/unit/templating/test_templating_util.py ..
tests/unit/unmarshalling/test_unmarshal.py ....................................................................x.........................
tests/unit/unmarshalling/test_validate.py ..................................................................................................................................................................................................
tests/unit/validation/test_request_shortcuts.py ..
tests/unit/validation/test_response_shortcuts.py ..

=============================== warnings summary ===============================
tests/integration/contrib/django/test_django_project.py::TestPetListView::test_get_no_required_param
  /usr/lib/python3.8/site-packages/django/conf/__init__.py:229: RemovedInDjango50Warning: The USE_L10N setting is deprecated. Starting with Django 5.0, localized formatting of data will always be enabled. For example Django will display numbers and dates using the format of the current locale.
    warnings.warn(USE_L10N_DEPRECATED_MSG, RemovedInDjango50Warning)

tests/integration/contrib/django/test_django_project.py: 96 warnings
tests/integration/contrib/falcon/test_falcon_project.py: 78 warnings
tests/integration/contrib/flask/test_flask_decorator.py: 2 warnings
tests/integration/contrib/flask/test_flask_validator.py: 5 warnings
tests/integration/contrib/flask/test_flask_views.py: 3 warnings
tests/integration/contrib/requests/test_requests_validation.py: 10 warnings
tests/integration/contrib/starlette/test_starlette_validation.py: 5 warnings
tests/integration/contrib/werkzeug/test_werkzeug_validation.py: 10 warnings
tests/integration/validation/test_petstore.py: 146 warnings
tests/integration/validation/test_read_only_write_only.py: 5 warnings
tests/integration/validation/test_security_override.py: 3 warnings
tests/integration/validation/test_validators.py: 51 warnings
tests/unit/unmarshalling/test_unmarshal.py: 4 warnings
tests/unit/unmarshalling/test_validate.py: 194 warnings
  /usr/lib/python3.8/site-packages/openapi_schema_validator/validators.py:120: DeprecationWarning: write property is deprecated. Use OAS30WriteValidator instead.
    warnings.warn(

tests/integration/contrib/django/test_django_project.py: 61 warnings
tests/integration/contrib/falcon/test_falcon_project.py: 61 warnings
tests/integration/contrib/flask/test_flask_decorator.py: 5 warnings
tests/integration/contrib/flask/test_flask_views.py: 8 warnings
tests/integration/contrib/requests/test_requests_validation.py: 4 warnings
tests/integration/contrib/starlette/test_starlette_validation.py: 4 warnings
tests/integration/contrib/werkzeug/test_werkzeug_validation.py: 4 warnings
tests/integration/validation/test_petstore.py: 161 warnings
tests/integration/validation/test_read_only_write_only.py: 5 warnings
tests/integration/validation/test_validators.py: 20 warnings
tests/unit/unmarshalling/test_unmarshal.py: 25 warnings
  /usr/lib/python3.8/site-packages/openapi_schema_validator/validators.py:113: DeprecationWarning: read property is deprecated. Use OAS30ReadValidator instead.
    warnings.warn(

tests/integration/contrib/requests/test_requests_validation.py::TestRequestsOpenAPIValidation::test_response_validator_path_pattern
  /usr/lib/python3.8/site-packages/responses/__init__.py:421: DeprecationWarning: Argument 'match_querystring' is deprecated. Use 'responses.matchers.query_param_matcher' or 'responses.matchers.query_string_matcher'
    warn(

tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerUnmarshal::test_schema_custom_format_invalid
tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerCall::test_string_format_custom
tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerCall::test_string_format_custom_value_error
  /home/tkloczko/rpmbuild/BUILDROOT/python-openapi-core-0.16.6-2.fc35.x86_64/usr/lib/python3.8/site-packages/openapi_core/unmarshalling/schemas/formatters.py:28: DeprecationWarning: Unmarshal method is deprecated. Rename unmarshal method to format instead.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
- generated xml file: /home/tkloczko/rpmbuild/BUILD/openapi-core-0.16.6/reports/junit.xml -
=========================== short test summary info ============================
XFAIL tests/unit/templating/test_paths_finders.py::TestOperationSimpleServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/templating/test_paths_finders.py::TestPathSimpleServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/templating/test_paths_finders.py::TestOperationVariableServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/templating/test_paths_finders.py::TestPathVariableServerServerNotFound::test_raises - returns default server
XFAIL tests/unit/unmarshalling/test_unmarshal.py::TestOAS30SchemaUnmarshallerCall::test_null_not_supported
XPASS tests/unit/templating/test_paths_finders.py::TestSpecSimpleServerServerNotFound::test_raises returns default server
XPASS tests/unit/templating/test_paths_finders.py::TestSpecVariableServerServerNotFound::test_raises returns default server
=========== 728 passed, 5 xfailed, 2 xpassed, 975 warnings in 4.16s ============

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

2 participants