Test environment
How the test database and Flask app are configured when tests run.
Table of contents
How it works
SPLENT_APPidentifies the active productget_create_app_in_testing_mode()callscreate_app("testing")- Flask picks up
TestingConfig:
class TestingConfig(Config):
TESTING = True
WTF_CSRF_ENABLED = False
def __init__(self):
super().__init__()
self.SQLALCHEMY_DATABASE_URI = _build_db_uri(
"MARIADB_TEST_DATABASE", "default_test_db"
)
Environment variables
| Variable | Default | Purpose |
|---|---|---|
MARIADB_USER |
default_user |
Database username |
MARIADB_PASSWORD |
default_password |
Database password |
MARIADB_HOSTNAME |
localhost |
Database host |
MARIADB_TEST_DATABASE |
default_test_db |
Test database name |
Tests always run inside the CLI container. The test database is separate from dev —
feature:testvalidates thatSQLALCHEMY_DATABASE_URIcontainstestbefore running.
Production guard
If SPLENT_ENV=prod is detected (in the product’s .env or from the running web container), tests refuse to run:
❌ Cannot run tests in production.
A production deployment is active.
Stop the deployment and start dev:
splent product:deploy --down
splent product:derive --dev
See also
- Fixtures — the test fixtures that create the app and reset the DB