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

Support python 3.11(TestCase) #1308

Closed
hyeongguen-song opened this issue Dec 21, 2022 · 3 comments
Closed

Support python 3.11(TestCase) #1308

hyeongguen-song opened this issue Dec 21, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@hyeongguen-song
Copy link
Contributor

hyeongguen-song commented Dec 21, 2022

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
If already support python 3.11, then I'm really sorry.

Describe the solution you'd like
A clear and concise description of what you want to happen.
Support python 3.11

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context about the feature request here.

connection is ok.
but at test case TestCase fail with python 3.11.1, tortoise-orm@0.19.2

Details
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/tortoise/contrib/test/__init__.py:297: in asyncSetUp
    await self.__transaction__.__aenter__()  # type: ignore
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/tortoise/contrib/test/__init__.py:273: in __aenter__
    self.connection._connection = await self.connection._parent._pool.acquire()
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/pool.py:838: in _acquire
    return await _acquire_impl()
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/pool.py:823: in _acquire_impl
    proxy = await ch.acquire()  # type: PoolConnectionProxy
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/pool.py:137: in acquire
    await self.connect()
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/pool.py:129: in connect
    self._con = await self._pool._get_new_connection()
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/pool.py:521: in _get_new_connection
    con = await connect_utils._connect_addr(
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/connect_utils.py:773: in _connect_addr
    return await __connect_addr(params, timeout, True, *args)
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/connect_utils.py:825: in __connect_addr
    tr, pr = await compat.wait_for(connector, timeout=timeout)
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/compat.py:56: in wait_for
    return await asyncio.wait_for(fut, timeout)
/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/asyncio/tasks.py:479: in wait_for
    return fut.result()
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/connect_utils.py:684: in _create_ssl_connection
    tr, pr = await loop.create_connection(
/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/asyncio/base_events.py:1039: in create_connection
    infos = await self._ensure_resolved(
/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/asyncio/base_events.py:1413: in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_UnixSelectorEventLoop running=False closed=False debug=False>
host = 'localhost', port = 15432
    async def getaddrinfo(self, host, port, *,
                          family=0, type=0, proto=0, flags=0):
        if self._debug:
            getaddr_func = self._getaddrinfo_debug
        else:
            getaddr_func = socket.getaddrinfo
    
>       return await self.run_in_executor(
            None, getaddr_func, host, port, family, type, proto, flags)
E       RuntimeError: Task <Task pending name='Task-782' coro=<_create_ssl_connection() running at /home/runner/.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/connect_utils.py:684> cb=[remove_from_cache() at /home/runner/.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/newrelic/hooks/coroutines_asyncio.py:20, _release_waiter(<Future pendi...events.py:427>)() at /opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/asyncio/tasks.py:421] created at /home/runner/.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/newrelic/common/object_wrapper.py:384> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/asyncio/futures.py:387]> attached to a different loop
/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/asyncio/base_events.py:867: RuntimeError
_______ TestAPI.test_api ________
self = <test_api.TestAPI testMethod=test_api>
    async def asyncSetUp(self) -> None:
>       await super().asyncSetUp()
app/tests/api/test_api.py:69: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/tortoise/contrib/test/__init__.py:297: in asyncSetUp
    await self.__transaction__.__aenter__()  # type: ignore
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/tortoise/contrib/test/__init__.py:273: in __aenter__
    self.connection._connection = await self.connection._parent._pool.acquire()
../../../.cache/pypoetry/virtualenvs/shopyo-sHG86FW6-py3.11/lib/python3.11/site-packages/asyncpg/pool.py:838: in _acquire
@hyeongguen-song hyeongguen-song changed the title Support python 3.11 Support python 3.11(TestCase) Dec 21, 2022
@long2ice long2ice added the enhancement New feature or request label Dec 23, 2022
@alexf-bond
Copy link

@hyeongguen-song I was able to get a containerized tortoise orm (0.19.0) application running/tested on python 3.11 using python:3.11.0-alpine3.17. If it's helpful here is the pyproject.toml deps:

[tool.poetry.dependencies]
python = "^3.11"
pytest-cov = "^2.10.1"
pytest-mock = "^3.3.1"
pytest-asyncio = "^0.18.1"
pytest-grpc = "^0.8.0"
requests-mock = "^1.8.0"
typing-extensions = "^3.7.4"
pytest-xdist = "^2.4.0"
flake8-print = "^4.0.0"
confluent-kafka = "^1.7.0"
aerich = "=0.6.2"
typed-ast = "^1.5.1"
asyncpg = "^0.27.0"
pydantic = "^1.8.2"
protobuf = "^3.19.1"
types-protobuf = "^3.18.2"
pytz = "^2021.3"
types-pytz = "^2021.3.0"
click = "<8.1.0"
tortoise-orm = "0.19.0"
python-dateutil = "^2.8.2"
datadog = "^0.44.0"
ddtrace = "^1.6.3"
psycopg2 = "^2.9.5"
grpcio = "^1.51.1"

Also I can provide more detail on the dockerfile / docker-compose and setup. Figured I'd chime in becase I spent last week trying to get our service upgraded to 3.11 as well. Cheers

@hyeongguen-song
Copy link
Contributor Author

@alexf-bond Thank you for favor.
Did you test with tortoise orm's TestCase? (maybe you did)

@alexf-bond
Copy link

I have not @hyeongguen-song :/, we're still using the db init fixture logic to spin up / down the database per test:

@pytest_asyncio.fixture(scope="function", autouse=True)
def initialize_tests(request):
    db_url = settings.POSTGRES_URI
    models = TORTOISE_ORM_CONFIG["apps"]["models"]["models"]
    initializer(models, db_url=db_url, app_label="models")
    _restore_default()
    connections.set("default", connections.get("models"))
    loop = asyncio.get_event_loop()
    loop.run_until_complete(init_sql())
    request.addfinalizer(finalizer)

We're using db transactions in the code we're testing so I wasn't sure how that'd interact with TestCase but i'd be happy to try on our 3.11 branch on a few of our tests and get back to you.

waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Feb 9, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue May 10, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue May 16, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue May 20, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jun 1, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jun 21, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jun 23, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jun 24, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jun 24, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jun 24, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jul 17, 2023
waketzheng added a commit to waketzheng/tortoise-orm that referenced this issue Jul 17, 2023
long2ice added a commit that referenced this issue Jul 20, 2023
…TION) (#1410)

* ci: add python3.11

* fix: testcase error with python3.11 (#1308)

* Compare safe schema sql with github action result

* chore: add comment

* Allow ForeignKeyField(on_delete=NO_ACTION) (#1393)

* fix Codacy complaint

* Update pydantic example to use OnDelete Enum

---------

Co-authored-by: long2ice <long2ice@gmail.com>
esrehmki pushed a commit to esrehmki/tortoise-orm that referenced this issue Aug 17, 2023
…TION) (tortoise#1410)

* ci: add python3.11

* fix: testcase error with python3.11 (tortoise#1308)

* Compare safe schema sql with github action result

* chore: add comment

* Allow ForeignKeyField(on_delete=NO_ACTION) (tortoise#1393)

* fix Codacy complaint

* Update pydantic example to use OnDelete Enum

---------

Co-authored-by: long2ice <long2ice@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants