diff --git a/Makefile b/Makefile index fa337fbc9..5b1f0e32c 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test_docs: bash scripts/test_docs.sh -svv test: - pytest + pytest -svv tests/ coverage: pytest --cov=ormar --cov=tests --cov-fail-under=100 --cov-report=term-missing tests diff --git a/benchmarks/conftest.py b/benchmarks/conftest.py index 083ab4c5c..7105a0684 100644 --- a/benchmarks/conftest.py +++ b/benchmarks/conftest.py @@ -7,10 +7,8 @@ import ormar import pytest import pytest_asyncio - -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() nest_asyncio.apply() diff --git a/docs_src/fastapi/docs001.py b/docs_src/fastapi/docs001.py index 68ee72dba..a290a95f8 100644 --- a/docs_src/fastapi/docs001.py +++ b/docs_src/fastapi/docs001.py @@ -2,10 +2,8 @@ import ormar from fastapi import FastAPI - -from tests.settings import create_config from tests.lifespan import lifespan - +from tests.settings import create_config base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) diff --git a/examples/fastapi_quick_start.py b/examples/fastapi_quick_start.py index 5883b8e8a..01bb0118f 100644 --- a/examples/fastapi_quick_start.py +++ b/examples/fastapi_quick_start.py @@ -24,6 +24,7 @@ async def lifespan(app: FastAPI): if database_.is_connected: await database_.disconnect() + app = FastAPI(lifespan=lifespan) metadata = sqlalchemy.MetaData() database = databases.Database("sqlite:///test.db") diff --git a/ormar/models/newbasemodel.py b/ormar/models/newbasemodel.py index 03743156f..366c8770d 100644 --- a/ormar/models/newbasemodel.py +++ b/ormar/models/newbasemodel.py @@ -891,7 +891,7 @@ def model_dump( # type: ignore # noqa A003 exclude_unset=exclude_unset, exclude_none=exclude_none, round_trip=round_trip, - warnings=warnings, + warnings=False, ) dict_instance = { @@ -994,7 +994,7 @@ def model_dump_json( # type: ignore # noqa A003 exclude_primary_keys=exclude_primary_keys, exclude_through_models=exclude_through_models, ) - return self.__pydantic_serializer__.to_json(data).decode() + return self.__pydantic_serializer__.to_json(data, warnings=False).decode() @classmethod @typing_extensions.deprecated( diff --git a/ormar/models/ormar_config.py b/ormar/models/ormar_config.py index e1895377e..e4941b18b 100644 --- a/ormar/models/ormar_config.py +++ b/ormar/models/ormar_config.py @@ -40,7 +40,7 @@ def __init__( self.pkname = None # type: ignore self.metadata = metadata self.database = database # type: ignore - self.engine = engine # type: ignore + self.engine = engine # type: ignore self.tablename = tablename # type: ignore self.orders_by = order_by or [] self.columns: List[sqlalchemy.Column] = [] diff --git a/tests/lifespan.py b/tests/lifespan.py index 684f358fd..afd786fc1 100644 --- a/tests/lifespan.py +++ b/tests/lifespan.py @@ -1,9 +1,9 @@ +from contextlib import asynccontextmanager +from typing import AsyncIterator + import pytest import sqlalchemy - -from contextlib import asynccontextmanager from fastapi import FastAPI -from typing import AsyncIterator def lifespan(config): diff --git a/tests/test_deferred/test_forward_cross_refs.py b/tests/test_deferred/test_forward_cross_refs.py index 56af4d776..8a87fc107 100644 --- a/tests/test_deferred/test_forward_cross_refs.py +++ b/tests/test_deferred/test_forward_cross_refs.py @@ -4,9 +4,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_deferred/test_forward_refs.py b/tests/test_deferred/test_forward_refs.py index 7842d37af..6208fa7fd 100644 --- a/tests/test_deferred/test_forward_refs.py +++ b/tests/test_deferred/test_forward_refs.py @@ -7,9 +7,8 @@ import sqlalchemy as sa from ormar.exceptions import ModelError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_deferred/test_more_same_table_joins.py b/tests/test_deferred/test_more_same_table_joins.py index 5cebb79d6..fc89f4094 100644 --- a/tests/test_deferred/test_more_same_table_joins.py +++ b/tests/test_deferred/test_more_same_table_joins.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_deferred/test_same_table_joins.py b/tests/test_deferred/test_same_table_joins.py index 548fded6b..2b0c9f89d 100644 --- a/tests/test_deferred/test_same_table_joins.py +++ b/tests/test_deferred/test_same_table_joins.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_encryption/test_encrypted_columns.py b/tests/test_encryption/test_encrypted_columns.py index 589886fd8..872fd4873 100644 --- a/tests/test_encryption/test_encrypted_columns.py +++ b/tests/test_encryption/test_encrypted_columns.py @@ -11,9 +11,8 @@ from ormar import ModelDefinitionError, NoMatch from ormar.fields.sqlalchemy_encrypted import EncryptedString -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() default_fernet = dict( diff --git a/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py b/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py index a70c74c58..322974c69 100644 --- a/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py +++ b/tests/test_exclude_include_dict/test_complex_relation_tree_performance.py @@ -1,14 +1,12 @@ from datetime import datetime from typing import List, Optional, Union -import databases import ormar as orm import pydantic import pytest -import sqlalchemy -from tests.settings import create_config from tests.lifespan import init_tests +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_exclude_include_dict/test_dumping_model_to_dict.py b/tests/test_exclude_include_dict/test_dumping_model_to_dict.py index 060b531c5..9c062cf8b 100644 --- a/tests/test_exclude_include_dict/test_dumping_model_to_dict.py +++ b/tests/test_exclude_include_dict/test_dumping_model_to_dict.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_exclude_include_dict/test_excludable_items.py b/tests/test_exclude_include_dict/test_excludable_items.py index e1fa142ff..a4338f501 100644 --- a/tests/test_exclude_include_dict/test_excludable_items.py +++ b/tests/test_exclude_include_dict/test_excludable_items.py @@ -3,8 +3,8 @@ import ormar from ormar.models.excludable import ExcludableItems -from tests.settings import create_config from tests.lifespan import init_tests +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py b/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py index 50120301e..cb2ce9470 100644 --- a/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py +++ b/tests/test_exclude_include_dict/test_excluding_fields_in_fastapi.py @@ -2,7 +2,6 @@ import random import string -import databases import ormar import pydantic import pytest @@ -13,10 +12,9 @@ from ormar import post_save from pydantic import ConfigDict, computed_field -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) diff --git a/tests/test_exclude_include_dict/test_excluding_fields_with_default.py b/tests/test_exclude_include_dict/test_excluding_fields_with_default.py index 23c5f87be..92dff49e6 100644 --- a/tests/test_exclude_include_dict/test_excluding_fields_with_default.py +++ b/tests/test_exclude_include_dict/test_excluding_fields_with_default.py @@ -4,9 +4,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py b/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py index d3f3aa845..71fe6a915 100644 --- a/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py +++ b/tests/test_exclude_include_dict/test_excluding_subset_of_columns.py @@ -4,9 +4,8 @@ import pydantic import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_exclude_include_dict/test_pydantic_dict_params.py b/tests/test_exclude_include_dict/test_pydantic_dict_params.py index a16d97e3a..ca23f281d 100644 --- a/tests/test_exclude_include_dict/test_pydantic_dict_params.py +++ b/tests/test_exclude_include_dict/test_pydantic_dict_params.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_fastapi/test_binary_fields.py b/tests/test_fastapi/test_binary_fields.py index 3142cbd62..41343c669 100644 --- a/tests/test_fastapi/test_binary_fields.py +++ b/tests/test_fastapi/test_binary_fields.py @@ -1,7 +1,7 @@ import base64 import uuid from enum import Enum -from typing import List +from typing import List import ormar import pytest @@ -9,9 +9,8 @@ from fastapi import FastAPI from httpx import AsyncClient +from tests.lifespan import init_tests, lifespan from tests.settings import create_config -from tests.lifespan import lifespan, init_tests - headers = {"content-type": "application/json"} base_ormar_config = create_config() diff --git a/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py b/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py index 943653f77..43df07240 100644 --- a/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py +++ b/tests/test_fastapi/test_docs_with_multiple_relations_to_one.py @@ -7,9 +7,8 @@ from fastapi import FastAPI from httpx import AsyncClient +from tests.lifespan import init_tests, lifespan from tests.settings import create_config -from tests.lifespan import lifespan, init_tests - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) diff --git a/tests/test_fastapi/test_enum_schema.py b/tests/test_fastapi/test_enum_schema.py index a6431128c..da1f7c027 100644 --- a/tests/test_fastapi/test_enum_schema.py +++ b/tests/test_fastapi/test_enum_schema.py @@ -2,9 +2,8 @@ import ormar -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_fastapi/test_excludes_with_get_pydantic.py b/tests/test_fastapi/test_excludes_with_get_pydantic.py index a06a6e365..73727eff9 100644 --- a/tests/test_fastapi/test_excludes_with_get_pydantic.py +++ b/tests/test_fastapi/test_excludes_with_get_pydantic.py @@ -1,13 +1,13 @@ +from typing import ForwardRef, Optional + import ormar import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import AsyncClient -from typing import ForwardRef, Optional +from tests.lifespan import init_tests, lifespan from tests.settings import create_config -from tests.lifespan import lifespan, init_tests - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) diff --git a/tests/test_fastapi/test_excluding_fields.py b/tests/test_fastapi/test_excluding_fields.py index 6c33a1711..c4f951199 100644 --- a/tests/test_fastapi/test_excluding_fields.py +++ b/tests/test_fastapi/test_excluding_fields.py @@ -6,7 +6,7 @@ from fastapi import FastAPI from httpx import AsyncClient -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config base_ormar_config = create_config() @@ -31,7 +31,6 @@ class Item(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.post("/items/", response_model=Item) async def create_item(item: Item): await item.save_related(follow=True, save_all=True) diff --git a/tests/test_fastapi/test_extra_ignore_parameter.py b/tests/test_fastapi/test_extra_ignore_parameter.py index 71b1219db..183ee2751 100644 --- a/tests/test_fastapi/test_extra_ignore_parameter.py +++ b/tests/test_fastapi/test_extra_ignore_parameter.py @@ -5,7 +5,7 @@ from httpx import AsyncClient from ormar import Extra -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config base_ormar_config = create_config() @@ -22,7 +22,6 @@ class Item(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.post("/item/", response_model=Item) async def create_item(item: Item): return await item.save() diff --git a/tests/test_fastapi/test_fastapi_docs.py b/tests/test_fastapi/test_fastapi_docs.py index 698a4ae35..ca1d8929d 100644 --- a/tests/test_fastapi/test_fastapi_docs.py +++ b/tests/test_fastapi/test_fastapi_docs.py @@ -9,10 +9,9 @@ from httpx import AsyncClient from pydantic import Field -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) @@ -49,7 +48,6 @@ class Item(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.get("/items/", response_model=List[Item]) async def get_items(): items = await Item.objects.select_related("categories").all() diff --git a/tests/test_fastapi/test_fastapi_usage.py b/tests/test_fastapi/test_fastapi_usage.py index ed2f9046e..ec32de1e2 100644 --- a/tests/test_fastapi/test_fastapi_usage.py +++ b/tests/test_fastapi/test_fastapi_usage.py @@ -6,9 +6,8 @@ from fastapi import FastAPI from httpx import AsyncClient +from tests.lifespan import init_tests, lifespan from tests.settings import create_config -from tests.lifespan import lifespan, init_tests - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) @@ -32,7 +31,6 @@ class Item(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.post("/items/", response_model=Item) async def create_item(item: Item): return item diff --git a/tests/test_fastapi/test_inheritance_concrete_fastapi.py b/tests/test_fastapi/test_inheritance_concrete_fastapi.py index 3504a4989..8a582fb7d 100644 --- a/tests/test_fastapi/test_inheritance_concrete_fastapi.py +++ b/tests/test_fastapi/test_inheritance_concrete_fastapi.py @@ -1,18 +1,17 @@ import datetime from typing import List, Optional -import pytest import ormar +import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import AsyncClient from ormar.relations.relation_proxy import RelationProxy from pydantic import computed_field -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) @@ -137,7 +136,6 @@ class Truck2(Car2): create_test_database = init_tests(base_ormar_config) - @app.post("/subjects/", response_model=Subject) async def create_item(item: Subject): return item diff --git a/tests/test_fastapi/test_inheritance_mixins_fastapi.py b/tests/test_fastapi/test_inheritance_mixins_fastapi.py index fa7289079..2c8c1838e 100644 --- a/tests/test_fastapi/test_inheritance_mixins_fastapi.py +++ b/tests/test_fastapi/test_inheritance_mixins_fastapi.py @@ -1,16 +1,15 @@ import datetime +from typing import Optional -import pytest import ormar +import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI from httpx import AsyncClient -from typing import Optional -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) @@ -44,7 +43,6 @@ class Subject(ormar.Model, DateFieldsMixins): create_test_database = init_tests(base_ormar_config) - @app.post("/subjects/", response_model=Subject) async def create_item(item: Subject): return item diff --git a/tests/test_fastapi/test_json_field_fastapi.py b/tests/test_fastapi/test_json_field_fastapi.py index 394e23e38..282c35371 100644 --- a/tests/test_fastapi/test_json_field_fastapi.py +++ b/tests/test_fastapi/test_json_field_fastapi.py @@ -9,10 +9,9 @@ from fastapi import FastAPI from httpx import AsyncClient -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) diff --git a/tests/test_fastapi/test_m2m_forwardref.py b/tests/test_fastapi/test_m2m_forwardref.py index 4d5e5f1f7..20c10bf41 100644 --- a/tests/test_fastapi/test_m2m_forwardref.py +++ b/tests/test_fastapi/test_m2m_forwardref.py @@ -7,10 +7,9 @@ from httpx import AsyncClient from starlette import status -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) @@ -54,7 +53,6 @@ class City(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.post("/", response_model=Country, status_code=status.HTTP_201_CREATED) async def create_country(country: Country): # if this is ormar result = await country.upsert() # it's already initialized as ormar model diff --git a/tests/test_fastapi/test_more_reallife_fastapi.py b/tests/test_fastapi/test_more_reallife_fastapi.py index 3540ad31c..fc9c08c5a 100644 --- a/tests/test_fastapi/test_more_reallife_fastapi.py +++ b/tests/test_fastapi/test_more_reallife_fastapi.py @@ -6,10 +6,9 @@ from fastapi import FastAPI from httpx import AsyncClient -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) @@ -32,7 +31,6 @@ class Item(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.get("/items", response_model=List[Item]) async def get_items(): items = await Item.objects.select_related("category").all() diff --git a/tests/test_fastapi/test_nested_saving.py b/tests/test_fastapi/test_nested_saving.py index e5827ca66..8b6992766 100644 --- a/tests/test_fastapi/test_nested_saving.py +++ b/tests/test_fastapi/test_nested_saving.py @@ -7,10 +7,9 @@ from httpx import AsyncClient from ormar.queryset.utils import translate_list_to_dict -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) headers = {"content-type": "application/json"} diff --git a/tests/test_fastapi/test_recursion_error.py b/tests/test_fastapi/test_recursion_error.py index 962d0a21e..ef6b91e6e 100644 --- a/tests/test_fastapi/test_recursion_error.py +++ b/tests/test_fastapi/test_recursion_error.py @@ -9,7 +9,7 @@ from httpx import AsyncClient from pydantic import BaseModel, Json -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config base_ormar_config = create_config() @@ -77,7 +77,6 @@ class Quiz(ormar.Model): create_test_database = init_tests(base_ormar_config) - async def get_current_user(): return await User(email="mail@example.com", username="aa", password="pass").save() diff --git a/tests/test_fastapi/test_relations_with_nested_defaults.py b/tests/test_fastapi/test_relations_with_nested_defaults.py index 6a7a4a8bd..ebbb6c77f 100644 --- a/tests/test_fastapi/test_relations_with_nested_defaults.py +++ b/tests/test_fastapi/test_relations_with_nested_defaults.py @@ -7,10 +7,9 @@ from fastapi import FastAPI from httpx import AsyncClient -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) diff --git a/tests/test_fastapi/test_schema_not_allowed_params.py b/tests/test_fastapi/test_schema_not_allowed_params.py index c5555802c..5147f9128 100644 --- a/tests/test_fastapi/test_schema_not_allowed_params.py +++ b/tests/test_fastapi/test_schema_not_allowed_params.py @@ -1,11 +1,8 @@ -import databases import ormar -import sqlalchemy from tests.lifespan import init_tests from tests.settings import create_config - base_ormar_config = create_config() diff --git a/tests/test_fastapi/test_skip_reverse_models.py b/tests/test_fastapi/test_skip_reverse_models.py index 5eef08573..fd06ae0a7 100644 --- a/tests/test_fastapi/test_skip_reverse_models.py +++ b/tests/test_fastapi/test_skip_reverse_models.py @@ -6,10 +6,9 @@ from fastapi import FastAPI from httpx import AsyncClient -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) headers = {"content-type": "application/json"} @@ -46,7 +45,6 @@ class Post(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.post("/categories/forbid/", response_model=Category2) async def create_category_forbid(category: Category2): # pragma: no cover pass diff --git a/tests/test_fastapi/test_wekref_exclusion.py b/tests/test_fastapi/test_wekref_exclusion.py index 6002dc484..bcaf5227f 100644 --- a/tests/test_fastapi/test_wekref_exclusion.py +++ b/tests/test_fastapi/test_wekref_exclusion.py @@ -8,10 +8,9 @@ from fastapi import FastAPI from httpx import AsyncClient -from tests.lifespan import lifespan, init_tests +from tests.lifespan import init_tests, lifespan from tests.settings import create_config - base_ormar_config = create_config() app = FastAPI(lifespan=lifespan(base_ormar_config)) @@ -36,7 +35,6 @@ class Thing(ormar.Model): create_test_database = init_tests(base_ormar_config) - @app.post("/test/1") async def post_test_1(): # don't split initialization and attribute assignment diff --git a/tests/test_inheritance_and_pydantic_generation/test_excluding_parent_fields_inheritance.py b/tests/test_inheritance_and_pydantic_generation/test_excluding_parent_fields_inheritance.py index a50cd0977..a083a29cc 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_excluding_parent_fields_inheritance.py +++ b/tests/test_inheritance_and_pydantic_generation/test_excluding_parent_fields_inheritance.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py b/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py index b9f1e525c..5ca9a3e89 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py +++ b/tests/test_inheritance_and_pydantic_generation/test_geting_pydantic_models.py @@ -1,14 +1,11 @@ from typing import ForwardRef, List, Optional -import databases import ormar import pydantic -import sqlalchemy from pydantic_core import PydanticUndefined -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py index 6046e0e31..aa4d7756b 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_concrete.py @@ -13,12 +13,12 @@ from ormar.relations.relation_proxy import RelationProxy from pydantic import computed_field -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() + class AuditModel(ormar.Model): ormar_config = base_ormar_config.copy(abstract=True) diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py index 923c0c897..68a6b91dd 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_mixins.py @@ -5,9 +5,8 @@ import pytest import sqlalchemy as sa -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py index f8d9834ee..6b87cef3f 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_of_property_fields.py @@ -1,9 +1,8 @@ import ormar from pydantic import computed_field -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py b/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py index 900b0ffe3..bd93e79e0 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inheritance_with_default.py @@ -4,9 +4,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py b/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py index 44a75791d..0f4352521 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py +++ b/tests/test_inheritance_and_pydantic_generation/test_inherited_class_is_not_abstract_by_default.py @@ -1,13 +1,10 @@ import datetime -import databases import ormar import pytest -import sqlalchemy -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py b/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py index 87a2b7bad..b73698f70 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py +++ b/tests/test_inheritance_and_pydantic_generation/test_nested_models_pydantic.py @@ -1,8 +1,7 @@ import ormar -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py b/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py index f4661338d..58bf96c94 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py +++ b/tests/test_inheritance_and_pydantic_generation/test_pydantic_fields_order.py @@ -1,8 +1,7 @@ import ormar -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py b/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py index 7afb2cb77..e6f1b5e7d 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py +++ b/tests/test_inheritance_and_pydantic_generation/test_validators_are_inherited.py @@ -4,9 +4,8 @@ import pytest from pydantic import ValidationError, field_validator -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py b/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py index 96ebc17c6..b8fce0dd3 100644 --- a/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py +++ b/tests/test_inheritance_and_pydantic_generation/test_validators_in_generated_pydantic.py @@ -4,9 +4,8 @@ import pytest from pydantic import ValidationError, field_validator -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_meta_constraints/test_check_constraints.py b/tests/test_meta_constraints/test_check_constraints.py index 4af656464..88084c333 100644 --- a/tests/test_meta_constraints/test_check_constraints.py +++ b/tests/test_meta_constraints/test_check_constraints.py @@ -4,9 +4,8 @@ import ormar.fields.constraints import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_meta_constraints/test_index_constraints.py b/tests/test_meta_constraints/test_index_constraints.py index 291839628..e3a21908a 100644 --- a/tests/test_meta_constraints/test_index_constraints.py +++ b/tests/test_meta_constraints/test_index_constraints.py @@ -1,9 +1,8 @@ import ormar.fields.constraints import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_meta_constraints/test_unique_constraints.py b/tests/test_meta_constraints/test_unique_constraints.py index 64da9ad5b..d1abd91f4 100644 --- a/tests/test_meta_constraints/test_unique_constraints.py +++ b/tests/test_meta_constraints/test_unique_constraints.py @@ -5,9 +5,8 @@ import pymysql import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_aliases.py b/tests/test_model_definition/test_aliases.py index 13fbb530d..0bd3d1a81 100644 --- a/tests/test_model_definition/test_aliases.py +++ b/tests/test_model_definition/test_aliases.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_columns.py b/tests/test_model_definition/test_columns.py index 94b24f862..3fbf8f898 100644 --- a/tests/test_model_definition/test_columns.py +++ b/tests/test_model_definition/test_columns.py @@ -6,9 +6,8 @@ import pytest from ormar import ModelDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_model_definition/test_create_uses_init_for_consistency.py b/tests/test_model_definition/test_create_uses_init_for_consistency.py index 736248008..80cd7729f 100644 --- a/tests/test_model_definition/test_create_uses_init_for_consistency.py +++ b/tests/test_model_definition/test_create_uses_init_for_consistency.py @@ -5,9 +5,8 @@ import pytest from pydantic import model_validator -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_dates_with_timezone.py b/tests/test_model_definition/test_dates_with_timezone.py index 954ca350e..42917ecee 100644 --- a/tests/test_model_definition/test_dates_with_timezone.py +++ b/tests/test_model_definition/test_dates_with_timezone.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_equality_and_hash.py b/tests/test_model_definition/test_equality_and_hash.py index 0d46dadf0..f5b3cd335 100644 --- a/tests/test_model_definition/test_equality_and_hash.py +++ b/tests/test_model_definition/test_equality_and_hash.py @@ -2,9 +2,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_extra_ignore_parameter.py b/tests/test_model_definition/test_extra_ignore_parameter.py index 7f20cc503..733faf2b4 100644 --- a/tests/test_model_definition/test_extra_ignore_parameter.py +++ b/tests/test_model_definition/test_extra_ignore_parameter.py @@ -1,9 +1,8 @@ import ormar from ormar import Extra -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_model_definition/test_fields_access.py b/tests/test_model_definition/test_fields_access.py index c457f1438..538f8258c 100644 --- a/tests/test_model_definition/test_fields_access.py +++ b/tests/test_model_definition/test_fields_access.py @@ -1,12 +1,9 @@ -import databases import ormar import pytest -import sqlalchemy from ormar import BaseField -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py b/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py index 5ebc7f9bb..6f0e9b7b4 100644 --- a/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py +++ b/tests/test_model_definition/test_foreign_key_value_used_for_related_model.py @@ -4,9 +4,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_iterate.py b/tests/test_model_definition/test_iterate.py index c5a9f78f0..31e64ffd9 100644 --- a/tests/test_model_definition/test_iterate.py +++ b/tests/test_model_definition/test_iterate.py @@ -4,9 +4,8 @@ import pytest from ormar.exceptions import QueryDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_model_construct.py b/tests/test_model_definition/test_model_construct.py index 85ad4101d..b4f7ce385 100644 --- a/tests/test_model_definition/test_model_construct.py +++ b/tests/test_model_definition/test_model_construct.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_model_definition.py b/tests/test_model_definition/test_model_definition.py index 7d841bf18..d3ca604f0 100644 --- a/tests/test_model_definition/test_model_definition.py +++ b/tests/test_model_definition/test_model_definition.py @@ -10,9 +10,8 @@ from ormar.exceptions import ModelDefinitionError from ormar.models import Model -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_models.py b/tests/test_model_definition/test_models.py index 951edafd1..452696e36 100644 --- a/tests/test_model_definition/test_models.py +++ b/tests/test_model_definition/test_models.py @@ -11,9 +11,8 @@ import sqlalchemy from ormar.exceptions import ModelError, NoMatch, QueryDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_models_are_pickable.py b/tests/test_model_definition/test_models_are_pickable.py index c0c90e1f0..4ce741548 100644 --- a/tests/test_model_definition/test_models_are_pickable.py +++ b/tests/test_model_definition/test_models_are_pickable.py @@ -4,9 +4,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_overwriting_pydantic_field_type.py b/tests/test_model_definition/test_overwriting_pydantic_field_type.py index bb026415d..d2d4fb0ae 100644 --- a/tests/test_model_definition/test_overwriting_pydantic_field_type.py +++ b/tests/test_model_definition/test_overwriting_pydantic_field_type.py @@ -4,9 +4,8 @@ import pytest from pydantic import Json, PositiveInt, ValidationError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_overwriting_sql_nullable.py b/tests/test_model_definition/test_overwriting_sql_nullable.py index f967f05bd..699292164 100644 --- a/tests/test_model_definition/test_overwriting_sql_nullable.py +++ b/tests/test_model_definition/test_overwriting_sql_nullable.py @@ -7,9 +7,8 @@ import pytest from sqlalchemy import text -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_pk_field_is_always_not_null.py b/tests/test_model_definition/test_pk_field_is_always_not_null.py index 285c82dc3..4737a4b08 100644 --- a/tests/test_model_definition/test_pk_field_is_always_not_null.py +++ b/tests/test_model_definition/test_pk_field_is_always_not_null.py @@ -1,8 +1,7 @@ import ormar -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_properties.py b/tests/test_model_definition/test_properties.py index 085f6e030..863f09387 100644 --- a/tests/test_model_definition/test_properties.py +++ b/tests/test_model_definition/test_properties.py @@ -3,9 +3,8 @@ import pytest from pydantic import PydanticUserError, computed_field -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_pydantic_fields.py b/tests/test_model_definition/test_pydantic_fields.py index ff9b1e474..8fec91c35 100644 --- a/tests/test_model_definition/test_pydantic_fields.py +++ b/tests/test_model_definition/test_pydantic_fields.py @@ -6,9 +6,8 @@ from pydantic import BaseModel, Field, HttpUrl from pydantic_extra_types.payment import PaymentCardNumber -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_pydantic_only_fields.py b/tests/test_model_definition/test_pydantic_only_fields.py index 024ecba3c..49800b015 100644 --- a/tests/test_model_definition/test_pydantic_only_fields.py +++ b/tests/test_model_definition/test_pydantic_only_fields.py @@ -5,9 +5,8 @@ import pytest from pydantic import computed_field -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_pydantic_private_attributes.py b/tests/test_model_definition/test_pydantic_private_attributes.py index 591dabaea..64d7f8340 100644 --- a/tests/test_model_definition/test_pydantic_private_attributes.py +++ b/tests/test_model_definition/test_pydantic_private_attributes.py @@ -3,9 +3,8 @@ import ormar from pydantic import PrivateAttr -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_save_status.py b/tests/test_model_definition/test_save_status.py index 52f58fb32..a2bab8f9b 100644 --- a/tests/test_model_definition/test_save_status.py +++ b/tests/test_model_definition/test_save_status.py @@ -4,9 +4,8 @@ import pytest from ormar.exceptions import ModelPersistenceError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_saving_nullable_fields.py b/tests/test_model_definition/test_saving_nullable_fields.py index 05a2a9405..456781405 100644 --- a/tests/test_model_definition/test_saving_nullable_fields.py +++ b/tests/test_model_definition/test_saving_nullable_fields.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_server_default.py b/tests/test_model_definition/test_server_default.py index 089d78463..a181d7905 100644 --- a/tests/test_model_definition/test_server_default.py +++ b/tests/test_model_definition/test_server_default.py @@ -5,9 +5,8 @@ import pytest from sqlalchemy import func, text -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_definition/test_setting_comments_in_db.py b/tests/test_model_definition/test_setting_comments_in_db.py index 08388be5c..30bc33693 100644 --- a/tests/test_model_definition/test_setting_comments_in_db.py +++ b/tests/test_model_definition/test_setting_comments_in_db.py @@ -2,9 +2,8 @@ import pytest from ormar.models import Model -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_methods/test_excludes_in_load_all.py b/tests/test_model_methods/test_excludes_in_load_all.py index 49811e386..6b9b08744 100644 --- a/tests/test_model_methods/test_excludes_in_load_all.py +++ b/tests/test_model_methods/test_excludes_in_load_all.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_model_methods/test_load_all.py b/tests/test_model_methods/test_load_all.py index af0452654..99d3ed2fb 100644 --- a/tests/test_model_methods/test_load_all.py +++ b/tests/test_model_methods/test_load_all.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_methods/test_populate_default_values.py b/tests/test_model_methods/test_populate_default_values.py index 820d313c1..8675f6794 100644 --- a/tests/test_model_methods/test_populate_default_values.py +++ b/tests/test_model_methods/test_populate_default_values.py @@ -1,9 +1,8 @@ import ormar from sqlalchemy import text -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_methods/test_save_related.py b/tests/test_model_methods/test_save_related.py index 7201050af..f12d3d158 100644 --- a/tests/test_model_methods/test_save_related.py +++ b/tests/test_model_methods/test_save_related.py @@ -1,13 +1,10 @@ from typing import List -import databases import ormar import pytest -import sqlalchemy -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_methods/test_save_related_from_dict.py b/tests/test_model_methods/test_save_related_from_dict.py index 089360ab5..c6a4e7ec9 100644 --- a/tests/test_model_methods/test_save_related_from_dict.py +++ b/tests/test_model_methods/test_save_related_from_dict.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_methods/test_save_related_uuid.py b/tests/test_model_methods/test_save_related_uuid.py index 2139cb573..5b425c680 100644 --- a/tests/test_model_methods/test_save_related_uuid.py +++ b/tests/test_model_methods/test_save_related_uuid.py @@ -1,14 +1,11 @@ import uuid from typing import Optional -import databases import ormar import pytest -import sqlalchemy -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_methods/test_update.py b/tests/test_model_methods/test_update.py index fbf11b823..f2cbd3398 100644 --- a/tests/test_model_methods/test_update.py +++ b/tests/test_model_methods/test_update.py @@ -1,13 +1,10 @@ from typing import Optional -import databases import ormar import pytest -import sqlalchemy -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_model_methods/test_upsert.py b/tests/test_model_methods/test_upsert.py index 43b241f1d..249054ce5 100644 --- a/tests/test_model_methods/test_upsert.py +++ b/tests/test_model_methods/test_upsert.py @@ -1,13 +1,10 @@ from typing import Optional -import databases import ormar import pytest -import sqlalchemy -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_ordering/test_default_model_order.py b/tests/test_ordering/test_default_model_order.py index 20bc4a608..4a7f4aacc 100644 --- a/tests/test_ordering/test_default_model_order.py +++ b/tests/test_ordering/test_default_model_order.py @@ -4,9 +4,8 @@ import pytest import pytest_asyncio -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_ordering/test_default_relation_order.py b/tests/test_ordering/test_default_relation_order.py index 6b20cc292..6e395a018 100644 --- a/tests/test_ordering/test_default_relation_order.py +++ b/tests/test_ordering/test_default_relation_order.py @@ -5,9 +5,8 @@ import pytest import pytest_asyncio -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_ordering/test_default_through_relation_order.py b/tests/test_ordering/test_default_through_relation_order.py index 1d0e1daa5..ed0889b76 100644 --- a/tests/test_ordering/test_default_through_relation_order.py +++ b/tests/test_ordering/test_default_through_relation_order.py @@ -12,9 +12,8 @@ pre_update, ) -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_ordering/test_proper_order_of_sorting_apply.py b/tests/test_ordering/test_proper_order_of_sorting_apply.py index 9f7c117b7..f6f805192 100644 --- a/tests/test_ordering/test_proper_order_of_sorting_apply.py +++ b/tests/test_ordering/test_proper_order_of_sorting_apply.py @@ -4,9 +4,8 @@ import pytest import pytest_asyncio -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_adding_related.py b/tests/test_queries/test_adding_related.py index 247999241..84a3f226b 100644 --- a/tests/test_queries/test_adding_related.py +++ b/tests/test_queries/test_adding_related.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_aggr_functions.py b/tests/test_queries/test_aggr_functions.py index c7986d783..ba8199dff 100644 --- a/tests/test_queries/test_aggr_functions.py +++ b/tests/test_queries/test_aggr_functions.py @@ -5,9 +5,8 @@ import pytest_asyncio from ormar.exceptions import QueryDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_deep_relations_select_all.py b/tests/test_queries/test_deep_relations_select_all.py index 3e7bc84f9..8e8eabc61 100644 --- a/tests/test_queries/test_deep_relations_select_all.py +++ b/tests/test_queries/test_deep_relations_select_all.py @@ -2,9 +2,8 @@ import pytest from sqlalchemy import func -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_filter_groups.py b/tests/test_queries/test_filter_groups.py index c0af4c8bf..5fd8c396f 100644 --- a/tests/test_queries/test_filter_groups.py +++ b/tests/test_queries/test_filter_groups.py @@ -2,9 +2,8 @@ import ormar -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_indirect_relations_to_self.py b/tests/test_queries/test_indirect_relations_to_self.py index ae4a91736..ca0e9a884 100644 --- a/tests/test_queries/test_indirect_relations_to_self.py +++ b/tests/test_queries/test_indirect_relations_to_self.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_isnull_filter.py b/tests/test_queries/test_isnull_filter.py index 4f7fc79ff..0f166caef 100644 --- a/tests/test_queries/test_isnull_filter.py +++ b/tests/test_queries/test_isnull_filter.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_nested_reverse_relations.py b/tests/test_queries/test_nested_reverse_relations.py index b55f11bcf..0c8069f4f 100644 --- a/tests/test_queries/test_nested_reverse_relations.py +++ b/tests/test_queries/test_nested_reverse_relations.py @@ -2,11 +2,9 @@ import ormar import pytest -import sqlalchemy -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_non_relation_fields_not_merged.py b/tests/test_queries/test_non_relation_fields_not_merged.py index 97b3c70a7..84500cb78 100644 --- a/tests/test_queries/test_non_relation_fields_not_merged.py +++ b/tests/test_queries/test_non_relation_fields_not_merged.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_or_filters.py b/tests/test_queries/test_or_filters.py index 05c2e556e..db61646b3 100644 --- a/tests/test_queries/test_or_filters.py +++ b/tests/test_queries/test_or_filters.py @@ -4,9 +4,8 @@ import pytest from ormar.exceptions import QueryDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_order_by.py b/tests/test_queries/test_order_by.py index 6c091805f..5f8ac9f81 100644 --- a/tests/test_queries/test_order_by.py +++ b/tests/test_queries/test_order_by.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_pagination.py b/tests/test_queries/test_pagination.py index 5215b9f89..790945b28 100644 --- a/tests/test_queries/test_pagination.py +++ b/tests/test_queries/test_pagination.py @@ -2,9 +2,8 @@ import pytest from ormar.exceptions import QueryDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_queryproxy_on_m2m_models.py b/tests/test_queries/test_queryproxy_on_m2m_models.py index 93a09b874..23de3d7b9 100644 --- a/tests/test_queries/test_queryproxy_on_m2m_models.py +++ b/tests/test_queries/test_queryproxy_on_m2m_models.py @@ -4,9 +4,8 @@ import pytest from ormar.exceptions import QueryDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_queryset_level_methods.py b/tests/test_queries/test_queryset_level_methods.py index 93805c28f..f223eb221 100644 --- a/tests/test_queries/test_queryset_level_methods.py +++ b/tests/test_queries/test_queryset_level_methods.py @@ -12,9 +12,8 @@ ) from pydantic import Json -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_queries/test_quoting_table_names_in_on_join_clause.py b/tests/test_queries/test_quoting_table_names_in_on_join_clause.py index 299246209..e74a9f698 100644 --- a/tests/test_queries/test_quoting_table_names_in_on_join_clause.py +++ b/tests/test_queries/test_quoting_table_names_in_on_join_clause.py @@ -5,9 +5,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_reserved_sql_keywords_escaped.py b/tests/test_queries/test_reserved_sql_keywords_escaped.py index ad0d3a45c..0998233a7 100644 --- a/tests/test_queries/test_reserved_sql_keywords_escaped.py +++ b/tests/test_queries/test_reserved_sql_keywords_escaped.py @@ -1,9 +1,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_queries/test_reverse_fk_queryset.py b/tests/test_queries/test_reverse_fk_queryset.py index 1a629b21e..28937084b 100644 --- a/tests/test_queries/test_reverse_fk_queryset.py +++ b/tests/test_queries/test_reverse_fk_queryset.py @@ -4,9 +4,8 @@ import pytest from ormar import NoMatch -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_selecting_subset_of_columns.py b/tests/test_queries/test_selecting_subset_of_columns.py index 90dc80550..d7b943981 100644 --- a/tests/test_queries/test_selecting_subset_of_columns.py +++ b/tests/test_queries/test_selecting_subset_of_columns.py @@ -7,9 +7,8 @@ import pytest import pytest_asyncio -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_queries/test_values_and_values_list.py b/tests/test_queries/test_values_and_values_list.py index bb67b38fe..c090e4ae5 100644 --- a/tests/test_queries/test_values_and_values_list.py +++ b/tests/test_queries/test_values_and_values_list.py @@ -6,9 +6,8 @@ import pytest_asyncio from ormar.exceptions import QueryDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_cascades.py b/tests/test_relations/test_cascades.py index a85e2a70b..22c079aeb 100644 --- a/tests/test_relations/test_cascades.py +++ b/tests/test_relations/test_cascades.py @@ -4,9 +4,8 @@ import pytest import pytest_asyncio -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_customizing_through_model_relation_names.py b/tests/test_relations/test_customizing_through_model_relation_names.py index 8a8f22204..1aa3630cc 100644 --- a/tests/test_relations/test_customizing_through_model_relation_names.py +++ b/tests/test_relations/test_customizing_through_model_relation_names.py @@ -1,9 +1,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_database_fk_creation.py b/tests/test_relations/test_database_fk_creation.py index 9566dcde5..390adcefd 100644 --- a/tests/test_relations/test_database_fk_creation.py +++ b/tests/test_relations/test_database_fk_creation.py @@ -5,9 +5,8 @@ import sqlalchemy from ormar.fields.foreign_key import validate_referential_action -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_foreign_keys.py b/tests/test_relations/test_foreign_keys.py index f3561c123..e77d9a1f1 100644 --- a/tests/test_relations/test_foreign_keys.py +++ b/tests/test_relations/test_foreign_keys.py @@ -4,9 +4,8 @@ import pytest from ormar.exceptions import MultipleMatches, NoMatch, RelationshipInstanceError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_m2m_through_fields.py b/tests/test_relations/test_m2m_through_fields.py index 99eacf0dd..82b1d6262 100644 --- a/tests/test_relations/test_m2m_through_fields.py +++ b/tests/test_relations/test_m2m_through_fields.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_relations/test_many_to_many.py b/tests/test_relations/test_many_to_many.py index ad1a6fb40..e52b56073 100644 --- a/tests/test_relations/test_many_to_many.py +++ b/tests/test_relations/test_many_to_many.py @@ -1,4 +1,3 @@ -import asyncio from typing import List, Optional import ormar @@ -6,9 +5,8 @@ import pytest_asyncio from ormar.exceptions import ModelPersistenceError, NoMatch, RelationshipInstanceError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) @@ -37,13 +35,6 @@ class Post(ormar.Model): author: Optional[Author] = ormar.ForeignKey(Author) -@pytest.fixture(scope="module") -def event_loop(): - loop = asyncio.get_event_loop() - yield loop - loop.close() - - create_test_database = init_tests(base_ormar_config) diff --git a/tests/test_relations/test_postgress_select_related_with_limit.py b/tests/test_relations/test_postgress_select_related_with_limit.py index 93b4e0914..a12d5b009 100644 --- a/tests/test_relations/test_postgress_select_related_with_limit.py +++ b/tests/test_relations/test_postgress_select_related_with_limit.py @@ -7,9 +7,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_relations/test_prefetch_related.py b/tests/test_relations/test_prefetch_related.py index 5a2dc245a..cb7b17dce 100644 --- a/tests/test_relations/test_prefetch_related.py +++ b/tests/test_relations/test_prefetch_related.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config(force_rollback=True) diff --git a/tests/test_relations/test_prefetch_related_multiple_models_relation.py b/tests/test_relations/test_prefetch_related_multiple_models_relation.py index ecaf722fc..2ffbab2e4 100644 --- a/tests/test_relations/test_prefetch_related_multiple_models_relation.py +++ b/tests/test_relations/test_prefetch_related_multiple_models_relation.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_python_style_relations.py b/tests/test_relations/test_python_style_relations.py index d9287ff4b..bfdb4b12b 100644 --- a/tests/test_relations/test_python_style_relations.py +++ b/tests/test_relations/test_python_style_relations.py @@ -4,9 +4,8 @@ import pytest import pytest_asyncio -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_relations_default_exception.py b/tests/test_relations/test_relations_default_exception.py index 2066caf33..0e18ca130 100644 --- a/tests/test_relations/test_relations_default_exception.py +++ b/tests/test_relations/test_relations_default_exception.py @@ -5,9 +5,8 @@ import pytest from ormar.exceptions import ModelDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_replacing_models_with_copy.py b/tests/test_relations/test_replacing_models_with_copy.py index 436a7006b..cf70e3388 100644 --- a/tests/test_relations/test_replacing_models_with_copy.py +++ b/tests/test_relations/test_replacing_models_with_copy.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_saving_related.py b/tests/test_relations/test_saving_related.py index 2c777a457..24668b905 100644 --- a/tests/test_relations/test_saving_related.py +++ b/tests/test_relations/test_saving_related.py @@ -4,9 +4,8 @@ import pytest from ormar.exceptions import ModelPersistenceError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_select_related_with_limit.py b/tests/test_relations/test_select_related_with_limit.py index 1be283a26..2bbe4eebe 100644 --- a/tests/test_relations/test_select_related_with_limit.py +++ b/tests/test_relations/test_select_related_with_limit.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py b/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py index 0f9beebbc..5ebaef7ad 100644 --- a/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py +++ b/tests/test_relations/test_select_related_with_m2m_and_pk_name_set.py @@ -7,9 +7,8 @@ import sqlalchemy from ormar import ModelDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_selecting_proper_table_prefix.py b/tests/test_relations/test_selecting_proper_table_prefix.py index b0de7e05a..9dfe3cdbb 100644 --- a/tests/test_relations/test_selecting_proper_table_prefix.py +++ b/tests/test_relations/test_selecting_proper_table_prefix.py @@ -3,9 +3,8 @@ import ormar import pytest -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_skipping_reverse.py b/tests/test_relations/test_skipping_reverse.py index 3cc49df8f..947741c49 100644 --- a/tests/test_relations/test_skipping_reverse.py +++ b/tests/test_relations/test_skipping_reverse.py @@ -4,9 +4,8 @@ import pytest import pytest_asyncio -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_through_relations_fail.py b/tests/test_relations/test_through_relations_fail.py index 5057d907b..e6fcfefab 100644 --- a/tests/test_relations/test_through_relations_fail.py +++ b/tests/test_relations/test_through_relations_fail.py @@ -4,9 +4,8 @@ import pytest from ormar import ModelDefinitionError -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_relations/test_weakref_checking.py b/tests/test_relations/test_weakref_checking.py index 3a666bbae..2af76200a 100644 --- a/tests/test_relations/test_weakref_checking.py +++ b/tests/test_relations/test_weakref_checking.py @@ -2,7 +2,6 @@ from tests.settings import create_config - base_ormar_config = create_config() from tests.lifespan import init_tests diff --git a/tests/test_signals/test_signals.py b/tests/test_signals/test_signals.py index 5e6405b8c..7a9f7e0e2 100644 --- a/tests/test_signals/test_signals.py +++ b/tests/test_signals/test_signals.py @@ -16,9 +16,8 @@ from ormar.exceptions import SignalDefinitionError from ormar.signals import SignalEmitter -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_signals/test_signals_for_relations.py b/tests/test_signals/test_signals_for_relations.py index 5db964a06..2ac2e23d3 100644 --- a/tests/test_signals/test_signals_for_relations.py +++ b/tests/test_signals/test_signals_for_relations.py @@ -11,9 +11,8 @@ pre_relation_remove, ) -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() diff --git a/tests/test_utils/test_queryset_utils.py b/tests/test_utils/test_queryset_utils.py index c5c86bd36..8c6320b37 100644 --- a/tests/test_utils/test_queryset_utils.py +++ b/tests/test_utils/test_queryset_utils.py @@ -7,9 +7,8 @@ update_dict_from_list, ) -from tests.settings import create_config from tests.lifespan import init_tests - +from tests.settings import create_config base_ormar_config = create_config() @@ -207,4 +206,5 @@ def test_sorting_models(): models = sort_models(models, orders_by) assert [model.id for model in models] == [1, 4, 2, 3, 5, 6] + create_test_database = init_tests(base_ormar_config)