Skip to content

Commit c75ea6c

Browse files
committed
Fix
1 parent d8bdb25 commit c75ea6c

File tree

2 files changed

+40
-41
lines changed

2 files changed

+40
-41
lines changed

.github/workflows/test.yml

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- master
77
tags:
8-
- 'v*.*.*'
8+
- "v*.*.*"
99
pull_request:
1010
branches:
1111
- master
@@ -15,58 +15,57 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [ '3.6', '3.7', '3.8' ]
19-
postgres-version: [ '9.6', '12.1' ]
18+
python-version: ["3.7", "3.8", "3.9"]
19+
postgres-version: ["9.6", "12.1"]
2020
services:
2121
postgres:
2222
image: fantix/postgres-ssl:${{ matrix.postgres-version }}
2323
env:
2424
POSTGRES_USER: gino
2525
ports:
26-
- 5432:5432
26+
- 5432:5432
2727
# needed because the postgres container does not provide a healthcheck
2828
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
2929
steps:
30-
- name: Checkout source code
31-
uses: actions/checkout@v1
32-
- name: Set up Python
33-
uses: actions/setup-python@v1
34-
with:
35-
python-version: ${{ matrix.python-version }}
36-
- name: virtualenv cache
37-
uses: actions/cache@preview
38-
with:
39-
path: ~/.cache/pypoetry/virtualenvs
40-
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles(format('{0}{1}', github.workspace, '/poetry.lock')) }}
41-
restore-keys: |
42-
${{ runner.os }}-${{ matrix.python-version }}-poetry-
43-
- name: Install Python dependencies
44-
run: |
45-
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
46-
$HOME/.poetry/bin/poetry install
47-
- name: Test with pytest
48-
env:
49-
DB_HOST: localhost
50-
DB_USER: gino
51-
run: |
52-
$HOME/.poetry/bin/poetry run pytest --cov=src --cov=examples --cov-fail-under=95 --cov-report xml
53-
- name: Check code format with black
54-
if: matrix.python-version >= '3.6'
55-
run: |
30+
- name: Checkout source code
31+
uses: actions/checkout@v1
32+
- name: Set up Python
33+
uses: actions/setup-python@v1
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
- name: virtualenv cache
37+
uses: actions/cache@preview
38+
with:
39+
path: ~/.cache/pypoetry/virtualenvs
40+
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles(format('{0}{1}', github.workspace, '/poetry.lock')) }}
41+
restore-keys: |
42+
${{ runner.os }}-${{ matrix.python-version }}-poetry-
43+
- name: Install Python dependencies
44+
run: |
45+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
46+
$HOME/.poetry/bin/poetry install
47+
- name: Test with pytest
48+
env:
49+
DB_HOST: localhost
50+
DB_USER: gino
51+
run: |
52+
$HOME/.poetry/bin/poetry run pytest --cov=src --cov=examples --cov-fail-under=95 --cov-report xml
53+
- name: Check code format with black
54+
run: |
5655
$HOME/.poetry/bin/poetry run black --check src
57-
- name: Submit coverage report
58-
if: matrix.python-version == '3.8' && matrix.postgres-version == '12.1' && github.ref == 'refs/heads/master'
59-
env:
60-
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_TOKEN }}
61-
run: |
62-
pip install codacy-coverage
63-
python-codacy-coverage -r coverage.xml
56+
- name: Submit coverage report
57+
if: matrix.python-version == '3.8' && matrix.postgres-version == '12.1' && github.ref == 'refs/heads/master'
58+
env:
59+
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_TOKEN }}
60+
run: |
61+
pip install codacy-coverage
62+
python-codacy-coverage -r coverage.xml
6463
release:
6564
runs-on: ubuntu-latest
6665
needs: test
6766
strategy:
6867
matrix:
69-
python-version: [ '3.8' ]
68+
python-version: ["3.8"]
7069
steps:
7170
- name: Checkout source code
7271
if: startsWith(github.ref, 'refs/tags/')

tests/test_gino_sanic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class User(db.Model):
4848

4949
@app.route("/")
5050
async def root(request):
51-
conn = await request["connection"].get_raw_connection()
51+
conn = await request.ctx.connection.get_raw_connection()
5252
# noinspection PyProtectedMember
5353
assert conn._holder._max_inactive_time == _MAX_INACTIVE_CONNECTION_LIFETIME
5454
return text("Hello, world!")
@@ -60,7 +60,7 @@ async def get_user(request, uid):
6060
if method == "1":
6161
return json((await q.gino.first_or_404()).to_dict())
6262
elif method == "2":
63-
return json((await request["connection"].first_or_404(q)).to_dict())
63+
return json((await request.ctx.connection.first_or_404(q)).to_dict())
6464
elif method == "3":
6565
return json((await db.bind.first_or_404(q)).to_dict())
6666
elif method == "4":
@@ -74,7 +74,7 @@ async def add_user(request):
7474
await u.query.gino.first_or_404()
7575
await db.first_or_404(u.query)
7676
await db.bind.first_or_404(u.query)
77-
await request["connection"].first_or_404(u.query)
77+
await request.ctx.connection.first_or_404(u.query)
7878
return json(u.to_dict())
7979

8080
e = await gino.create_engine(PG_URL)

0 commit comments

Comments
 (0)