Skip to content

Commit

Permalink
chore: align pre-commit hooks and run with --all-files (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
IdoKendo authored Oct 18, 2024
1 parent 9b8f42b commit 640d0fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
20 changes: 8 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
hooks:
- id: black
args: [--safe]
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: debug-statements
language_version: python3
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.269
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.12.0
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


@pytest.fixture()
@pytest.fixture
def _mock_db(mocker):
mocker.patch("databases.Database.connect", return_value=None)
mocker.patch("databases.Database.disconnect", return_value=None)
Expand Down
11 changes: 6 additions & 5 deletions tests/test_mysql_context_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from mysql_context_manager import MysqlConnector
from mysql_context_manager import __version__

Expand All @@ -17,7 +18,7 @@ def test_connection_string_with_schema_name():
assert connector.connection_string == "mysql://root@localhost:3306/team_avatar"


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_false_disconnect():
connector = MysqlConnector(hostname="localhost")
assert connector.connection is None
Expand All @@ -26,7 +27,7 @@ async def test_false_disconnect():


@pytest.mark.usefixtures("_mock_db")
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_query():
connector = MysqlConnector(hostname="localhost", schema="team_avatar")
async with connector as conn:
Expand All @@ -35,7 +36,7 @@ async def test_query():


@pytest.mark.usefixtures("_mock_db")
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_execute():
connector = MysqlConnector(hostname="localhost", schema="team_avatar")
async with connector as conn:
Expand All @@ -46,15 +47,15 @@ async def test_execute():


@pytest.mark.usefixtures("_mock_db")
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_query_without_connection():
connector = MysqlConnector(hostname="localhost", schema="team_avatar")
with pytest.raises(ConnectionError):
await connector.query("select name from users;")


@pytest.mark.usefixtures("_mock_db")
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_execute_without_connection():
connector = MysqlConnector(hostname="localhost", schema="team_avatar")
with pytest.raises(ConnectionError):
Expand Down

0 comments on commit 640d0fc

Please sign in to comment.