Test environment

How the test database and Flask app are configured when tests run.

Table of contents

How it works

  1. SPLENT_APP identifies the active product
  2. get_create_app_in_testing_mode() calls create_app("testing")
  3. 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:test validates that SQLALCHEMY_DATABASE_URI contains test before 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

Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es