Skip to main content

pytest-bdd-ewx

pytest-bdd-ewx is a pytest plugin that ships several hundred ready-made Gherkin steps, fixtures and API clients for testing the Energyworx platform end to end: upload a file, run a flow, check the stored timeseries, all from a .feature file and against a live environment.

It is installed together with ewx-cli, which the plugin uses to upload the configurations a scenario needs and to authenticate.

Prerequisites​

  • Python (see the version range on this page)
  • The gcloud CLI
  • A Google Account with access to the python-shared repository in the ewx-global Artifact Registry project. Ask Service Desk to grant it if you do not have it yet.

Authenticate once per machine:

gcloud auth application-default login

Installation​

The examples pin pytest-bdd-ewx, ewx-cli to 26.8.0, the version that matches platform release 26.08. Replace it with the version matching your environment, see Versioning. Python 3.13 to 3.14; the examples use 3.13.

Install with pip

mkdir my_ewx_tests
cd my_ewx_tests
python3.13 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install keyring keyrings.google-artifactregistry-auth
pip install \
--index-url https://europe-west1-python.pkg.dev/ewx-global/python-shared/simple/ \
--extra-index-url https://pypi.org/simple/ \
pytest-bdd-ewx==26.8.0 ewx-cli==26.8.0

Install with uv

Use this pyproject.toml as a starting point:

pyproject.toml
[project]
name = "my-ewx-tests"
version = "0.1.0"
description = "Automated BDD test project for Energyworx."
requires-python = ">=3.13,<3.14"
dependencies = [
"pytest>=8.4.2,<9.0.0",
"pytest-bdd>=8.1.0,<9.0.0",
"pytest-bdd-ewx==26.8.0",
"ewx-cli==26.8.0",
]

[tool.uv]
package = false

[[tool.uv.index]]
name = "ewx-global"
url = "https://europe-west1-python.pkg.dev/ewx-global/python-shared/simple/"
explicit = true

[tool.uv.sources]
pytest-bdd-ewx = { index = "ewx-global" }
ewx-cli = { index = "ewx-global" }

Then resolve and install:

gcloud auth application-default login
export UV_INDEX_EWX_GLOBAL_USERNAME=oauth2accesstoken
export UV_INDEX_EWX_GLOBAL_PASSWORD="$(gcloud auth print-access-token)"
uv sync --python 3.13

The access token expires after an hour. Re-run the UV_INDEX_EWX_GLOBAL_PASSWORD assignment when uv sync reports an authorization error.

The plugin registers itself with pytest through an entry point, so no conftest.py or environment variable is needed to load it. Verify with:

pytest --version && pip show pytest-bdd-ewx

Installation issues​

SymptomCause and fix
401/403 or Authorization error from pkg.devYour Google Account is not authenticated or has no access to the repository. Re-run gcloud auth application-default login; if it persists, ask Service Desk to check your access. With uv, re-export UV_INDEX_EWX_GLOBAL_PASSWORD, the token expires after an hour.
No matching distribution or doesn't match any versionspip is not looking at the Energyworx index (check --index-url) or the pinned version does not exist. Pins follow the platform release, see Versioning; 2.x versions are no longer published.
keyring backend not foundInstall keyring keyrings.google-artifactregistry-auth in the same environment before running pip install against the index.
Activate.ps1 cannot be loaded (Windows)Run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned once and reopen PowerShell.
Plugin not loaded in pytestConfirm pytest-bdd-ewx is installed in the active environment (pip show pytest-bdd-ewx).

If the problem persists, contact Service Desk with the full command, the full error output, your Python version and whether you use pip or uv.

Next steps​