Skip to content

Commit b5df4ab

Browse files
committed
Make test config more general
1 parent 4a47b24 commit b5df4ab

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

freenit/project/tests/conftest.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
import importlib
12
import os
3+
24
import pytest
35
from pytest_factoryboy import register
4-
from .factories import UserFactory
56

7+
from alembic import command
8+
from alembic.config import Config
9+
from name import app_name
10+
11+
from .factories import UserFactory
612

13+
alembic_cfg = Config("alembic.ini")
714
register(UserFactory)
815

916

1017
@pytest.fixture
1118
def db_setup():
12-
from freenit.app import app as fastapp
13-
from alembic.config import Config
14-
from alembic import command
19+
app = importlib.import_module(f"{app_name}.app")
1520

16-
alembic_cfg = Config("alembic.ini")
1721
command.upgrade(alembic_cfg, "head")
1822

19-
yield fastapp
23+
yield app.app
2024

2125
current_path = os.path.dirname(__file__)
22-
os.remove(f'{current_path}/../test.sqlite')
26+
os.remove(f"{current_path}/../test.sqlite")

freenit/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.2.10"
1+
version = "0.2.11"

tests/conftest.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
import importlib
12
import os
3+
24
import pytest
35
from pytest_factoryboy import register
4-
from .factories import UserFactory
56

7+
from alembic import command
8+
from alembic.config import Config
9+
from name import app_name
10+
11+
from .factories import UserFactory
612

13+
alembic_cfg = Config("alembic.ini")
714
register(UserFactory)
815

916

1017
@pytest.fixture
1118
def db_setup():
12-
from freenit.app import app as fastapp
13-
from alembic.config import Config
14-
from alembic import command
19+
app = importlib.import_module(f"{app_name}.app")
1520

16-
alembic_cfg = Config("alembic.ini")
1721
command.upgrade(alembic_cfg, "head")
1822

19-
yield fastapp
23+
yield app.app
2024

2125
current_path = os.path.dirname(__file__)
22-
os.remove(f'{current_path}/../test.sqlite')
26+
os.remove(f"{current_path}/../test.sqlite")

0 commit comments

Comments
 (0)