Skip to content

test_media_types_method - Test failure #547

Closed
@darless

Description

@darless

Latest github actions run with failure:
https://github.com/python-restx/flask-restx/actions/runs/5385063797/jobs/9773681086

Failure seen

self = <test_api_legacy.APITest object at 0x7f26f63ece50>, app = <Flask 'tests.conftest'>, mocker = <pytest_mock.plugin.MockerFixture object at 0x7f26f5f815b0>

    def test_media_types_method(self, app, mocker):
        api = restx.Api(app)
    
        with app.test_request_context(
            "/foo", headers={"Accept": "application/xml; q=.5"}
        ):
>           assert api.mediatypes_method()(mocker.Mock()) == [
                "application/xml",
                "application/json",
            ]
E           AssertionError: assert ['application/json'] == ['application...ication/json']
E             At index 0 diff: 'application/json' != 'application/xml'
E             Right contains one more item: 'application/json'
E             Use -v to get the full diff

tests/legacy/test_api_legacy.py:113: AssertionError

Reproduce

Looks like all python versions are failing in the same way.

python3 -m venv venv
. ./venv/bin/activate
pip3 install -r requirements/dev.txt
tox

Expected Behavior

Tests expects to see mediatypes as both application/json and application/xml

Actual Behavior

Test only sees application/json

Environment

$ pip3 list
Package           Version
----------------- -------
black             23.3.0 
cachetools        5.3.1  
chardet           5.1.0  
click             8.1.3  
colorama          0.4.6  
distlib           0.3.6  
filelock          3.12.2 
mypy-extensions   1.0.0  
packaging         23.1   
pathspec          0.11.1 
pip               20.0.2 
pkg-resources     0.0.0  
platformdirs      3.8.0  
pluggy            1.2.0  
pyproject-api     1.5.2  
setuptools        44.0.0 
tomli             2.0.1  
tox               4.6.3  
typing-extensions 4.6.3  
virtualenv        20.23.1

Additional info

Failure started about 3 weeks ago:

failure_started

From what I can see nothing changed in the repo since March. Looking at the good run and the bad run, the only differences are:

  • Werkzeug (Good: 2.3.4, Bad: 2.3.5)
  • urllib (Good: 2.0.2, Bad: 2.0.3)

Changing urllib to the old version didn't fix it.
Changing Werkzeug to the old 2.3.4 version fixed the failure.

Werkzeug 2.3.5 changlog: https://werkzeug.palletsprojects.com/en/2.3.x/changes/#version-2-3-5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions