Skip to content

Commit

Permalink
test: skip an asyncio test case not support for Python earlier than…
Browse files Browse the repository at this point in the history
… 3.11. adjust test sh script

ci: update pre-commit and ruff
  • Loading branch information
tanbro committed Mar 27, 2024
1 parent 6719f00 commit 3bbc5c4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# my ignores
package-lock.json
*.lock
src/**/_version.py
.env.*
*.env

Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: ^.+_sa_types?+\.py$
exclude: ^src/sqlalchemy_dlock(/asyncio)?/_sa_types(_backward)?\.py$

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -21,7 +21,7 @@ repos:
- id: check-docstring-first

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.3.4
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61", "setuptools_scm>=6.2"]
requires = ["setuptools>=64", "setuptools-scm>=8"]

[project]
name = "sqlalchemy-dlock"
Expand Down
6 changes: 5 additions & 1 deletion scripts/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ do
do
echo
echo "---------------------------------------------------------------"
echo "Test of ${PYTHON} ${REQUIRES}"
echo "Begin of ${PYTHON} ${REQUIRES}"
echo "---------------------------------------------------------------"
echo
TMPDIR=$(mktemp -d)
trap 'rm -rf $TMPDIR' EXIT
Expand All @@ -37,6 +38,9 @@ do
$TMPDIR/bin/python -m coverage report
)
echo
echo "---------------------------------------------------------------"
echo "End of ${PYTHON} ${REQUIRES}"
echo "---------------------------------------------------------------"
echo
done
done
1 change: 1 addition & 0 deletions src/sqlalchemy_dlock/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_version.py
10 changes: 8 additions & 2 deletions src/sqlalchemy_dlock/factory.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import sys
from importlib import import_module
from typing import Union, Type
from typing import Type, Union

from sqlalchemy.engine import Connection

from .lock.base import BaseSadLock, TConnectionOrSession
from .lock.base import BaseSadLock
from .utils import pascal_case, safe_name

if sys.version_info < (3, 12): # pragma: no cover
from ._sa_types_backward import TConnectionOrSession
else: # pragma: no cover
from ._sa_types import TConnectionOrSession

__all__ = ["create_sadlock"]


Expand Down
4 changes: 3 additions & 1 deletion tests/asyncio/test_pg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
from unittest import IsolatedAsyncioTestCase
import sys
from unittest import IsolatedAsyncioTestCase, skipIf
from uuid import uuid4

from sqlalchemy_dlock.asyncio import create_async_sadlock
Expand Down Expand Up @@ -34,6 +35,7 @@ async def test_simple_xact(self):
async with conn.begin():
self.assertTrue(await lck.acquire())

@skipIf(sys.version_info < (3, 11), "‘asyncio.Barrier’: New in version 3.11")
async def test_xact_coro(self):
key = uuid4().hex
for engine in get_engines():
Expand Down

0 comments on commit 3bbc5c4

Please sign in to comment.