diff --git a/pyproject.toml b/pyproject.toml index 8c9ad16..a388bed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ force_grid_wrap = 2 profile = "black" py_version = 312 src_paths = ["src"] +skip_glob = ["tests/conftest.py", "build/*", "dist/*",] [tool.pytest.ini_options] pythonpath = [ diff --git a/src/pytest_sqlalchemy_mock/base.py b/src/pytest_sqlalchemy_mock/base.py index d684e23..7fc0ce7 100644 --- a/src/pytest_sqlalchemy_mock/base.py +++ b/src/pytest_sqlalchemy_mock/base.py @@ -45,15 +45,11 @@ def session(connection): @pytest.fixture(scope="function") -def mocked_session( - connection, sqlalchemy_declarative_base, sqlalchemy_mock_config -): +def mocked_session(connection, sqlalchemy_declarative_base, sqlalchemy_mock_config): session: Session = sessionmaker()(bind=connection) if sqlalchemy_declarative_base and sqlalchemy_mock_config: - ModelMocker( - session, sqlalchemy_declarative_base, sqlalchemy_mock_config - ).create_all() + ModelMocker(session, sqlalchemy_declarative_base, sqlalchemy_mock_config).create_all() yield session session.close() diff --git a/src/pytest_sqlalchemy_mock/model_mocker.py b/src/pytest_sqlalchemy_mock/model_mocker.py index 097d2f8..5ac1ca4 100644 --- a/src/pytest_sqlalchemy_mock/model_mocker.py +++ b/src/pytest_sqlalchemy_mock/model_mocker.py @@ -3,7 +3,10 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from typing import List, Tuple + from typing import ( + List, + Tuple, + ) from sqlalchemy import Table from sqlalchemy.orm import Session diff --git a/tests/db.py b/tests/db.py index f84544e..d8bb646 100644 --- a/tests/db.py +++ b/tests/db.py @@ -1,8 +1,19 @@ from typing import List -from sqlalchemy import (Boolean, Column, DateTime, ForeignKey, Integer, String, - func) -from sqlalchemy.orm import Mapped, declarative_base, relationship +from sqlalchemy import ( + Boolean, + Column, + DateTime, + ForeignKey, + Integer, + String, + func, +) +from sqlalchemy.orm import ( + Mapped, + declarative_base, + relationship, +) from sqlalchemy.testing.schema import Table Base = declarative_base() @@ -12,9 +23,7 @@ "user_department", Base.metadata, Column("user_id", Integer, ForeignKey("user.id"), primary_key=True), - Column( - "department_id", Integer, ForeignKey("department.id"), primary_key=True - ), + Column("department_id", Integer, ForeignKey("department.id"), primary_key=True), ) diff --git a/tests/test_pytest_sqlalchemy_mock.py b/tests/test_pytest_sqlalchemy_mock.py index 8992fe8..154d816 100644 --- a/tests/test_pytest_sqlalchemy_mock.py +++ b/tests/test_pytest_sqlalchemy_mock.py @@ -1,7 +1,10 @@ from sqlalchemy import text from .data import MockData -from .db import Department, User +from .db import ( + Department, + User, +) def test_get_session(session): @@ -13,10 +16,7 @@ def test_session_user_table(session): def test_session_query_for_assocation_table(session): - assert ( - session.execute(text("SELECT count(*) from user_department")).scalar() - == 0 - ) + assert session.execute(text("SELECT count(*) from user_department")).scalar() == 0 def test_mocked_session_user_table(mocked_session):