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.


E2E and load variables

E2E and load tests run against a live server and read their own variables.

Variable Default Purpose
SELENIUM_GRID_URL unset Attach the Selenium driver to this grid hub instead of launching a local browser.
SELENIUM_BROWSER chrome Browser for E2E tests, chrome or firefox.
SELENIUM_TARGET_URL unset Base URL for E2E tests. Required with a grid, since the browser container resolves the URL and localhost would point at itself.
SPLENT_LOCUSTFILES unset Comma-separated glob patterns that replace the Locust bootstrap’s default locustfile discovery.

See E2E (Selenium) and Load (Locust) for details.


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