Skip to Content

run_pytest_addon.sh — Single‑addon pytest runner (Odoo 18)

Path: /srv/pmiverse/_pmiconfig/scripts/test/run_pytest_addon.sh

Purpose - Run pytest for a single addon’s tests/ folder against a disposable Postgres DB. - Initialize the DB with base if empty and install the target addon prior to tests. - Enforce PMIverse rules: explicit pytest-odoo loading, no installs inside tests.

Usage

/srv/pmiverse/_pmiconfig/scripts/test/run_pytest_addon.sh \
  -a <full_path_to_addon>/tests \
  -d <db_name> \
  -- --maxfail=1 -q

Required arguments - -a, --addon-tests path to the addon tests/ directory - -d, --database disposable database name

Behavior - Activates instance venv: /srv/pmiverse/_pmisuite18/venv - Uses OCB at: /srv/pmiverse/_pmisuite18/repos/OCB - Uses Odoo config: /srv/pmiverse/_pmisuite18/config/pmisuite18.conf - Creates DB if missing (createdb <name>) - If DB is empty, initializes with base - Auto-detects the addon name from the tests parent folder and installs it before pytest. - Reads optional tests/odoo_dependencies.txt and installs those Odoo addons in the same step. List one addon name per line; blank lines and full-line # comments are allowed. Names are validated before database operations. A nonempty declaration requires a test_* database. Missing files keep the existing target-addon-only behavior. - Runs pytest with: - env: PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 - args: -p pytest_odoo --odoo-config=... --odoo-database=... <tests_path>

Notes - External dependencies declared in __manifest__.py must be present in the venv (e.g., pyocclient). - Do not perform button_immediate_install() in tests; assert installed instead. - Declare optional integration apps as test dependencies, not production manifest dependencies, unless the installed addon itself requires them. Both single-addon and repository runs read this declaration automatically, including PyCharm configurations using this runner.

Examples

# Run tests for pmis_nextcloud
/srv/pmiverse/_pmiconfig/scripts/test/run_pytest_addon.sh \
  -a /srv/pmiverse/_pmisuite18/repos/pmiverse/testing/pmis_nextcloud/tests \
  -d test_pmis_nextcloud -- -q --maxfail=1

Reports (optional) - You can pass standard pytest args after --, e.g. --junitxml=... or coverage flags if pytest-cov is installed.