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

Enhancement for FastAPI lifespan support (#1371) #1397

Closed

Conversation

waketzheng
Copy link
Contributor

@waketzheng waketzheng commented May 31, 2023

Description

Separate register_tortoise to RegisterTortoise.init and RegisterTortoise.close function

Motivation and Context

Support fastapi's lifespan and compare old register format

How Has This Been Tested?

  • make style
  • make test_sqlite
  • cd examples/fastapi && pytest _tests.py

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@coveralls
Copy link

coveralls commented May 31, 2023

Pull Request Test Coverage Report for Build 5798325204

  • 0 of 25 (0.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 88.733%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/contrib/fastapi/init.py 0 25 0.0%
Files with Coverage Reduction New Missed Lines %
tortoise/contrib/fastapi/init.py 2 0%
Totals Coverage Status
Change from base Build 5645776199: -0.2%
Covered Lines: 5744
Relevant Lines: 6401

💛 - Coveralls

@long2ice
Copy link
Member

long2ice commented Jun 5, 2023

I feel that this PR is not much different from before the change. What about just adding the corresponding warning and updating the example and docs?

@waketzheng
Copy link
Contributor Author

Warning added, example and docs updated.

@waketzheng
Copy link
Contributor Author

@long2ice take a look at this, register_tortoise for fastapi compare with old version and support lifespan now.

@waketzheng waketzheng force-pushed the support-fastapi-lifespan branch 8 times, most recently from 160c2a5 to 81e899e Compare September 29, 2023 14:12
@waketzheng
Copy link
Contributor Author

@long2ice How to fix this unittest error:

Diff is 65175 characters long. Set self.maxDiff to None to see it. : Ellipsis
------------------------------ Captured log call -------------------------------
WARNING  asyncio:base_events.py:1904 Executing <Task pending name='Task-4589' coro=<IsolatedAsyncioTestCase._asyncioLoopRunner() running at /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/unittest/async_case.py:95> wait_for=<Future pending cb=[Task.task_wakeup()] created at /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/asyncio/base_events.py:429> created at /home/runner/work/tortoise-orm/tortoise-orm/tortoise/contrib/test/__init__.py:190> took 1562.231 seconds
=========================== short test summary info ============================
FAILED tests/test_bulk.py::TestBulk::test_bulk_create_mix_specified - AssertionError: Lists differ: [{'id': 2028, 'name': None}, {'id': 2029, 'name':[27970 chars]one}] != [{'id': 10000, 'name': None}, {'id': 10001, 'name[28946 chars]one}]

First differing element 0:
{'id': 2028, 'name': None}
{'id': 10000, 'name': None}

Diff is 65175 characters long. Set self.maxDiff to None to see it. : Ellipsis
1 failed, 1071 passed, 59 skipped, 3 xfailed in 1623.54s (0:27:03)
make: *** [Makefile:53: test_postgres_psycopg] Error 1

@waketzheng
Copy link
Contributor Author

ci failed, but my local test success. Move it to #1541

@waketzheng waketzheng closed this Jan 7, 2024
@waketzheng waketzheng deleted the support-fastapi-lifespan branch May 8, 2024 14:33
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

Successfully merging this pull request may close these issues.

4 participants