Is it possible to create a separate database to use with pytest tests, similar to how it is described here ?
If you’re using all the builtin stuff and you want a separate db for each test, try this
import sys
import pytest
import reflex as rx
sys.path.append(".")
from repro_model_link_table.repro_model_link_table import State
@pytest.fixture(autouse=True)
def db(tmp_path):
rx.config.get_config().db_url = f"sqlite:///{tmp_path}/reflex.db"
print(rx.config.get_config())
rx.Model.migrate()
def test_create_user():
state = State()
state.load_users()
assert len(state.users) == 0
state.create_user()
state.load_users()
assert len(state.users) == 1
def test_create_multiple_users():
state = State()
state.load_users()
assert len(state.users) == 0
state.create_user()
state.create_user()
state.create_user()
state.load_users()
assert len(state.users) == 3