Robot Framework library to override test variables from .env files
Project description
EnvManageLibrary
Robot Framework keyword library that overrides test variables with values from .env files.
Variables loaded via Robot Framework's Variables directive (from YAML files) are automatically matched against .env entries and overridden at test-case scope.
Installation
Option 1: From PyPI
pip install robotframework-env-manage-library
Option 2: From local .whl / .tar.gz file
pip install robotframework_env_manage_library-0.1.0-py3-none-any.whl
Option 3: From local packages directory (offline)
pip install --no-index --find-links=./packages robotframework-env-manage-library
.env Naming Convention
The dot (.) separator distinguishes nested dict keys from flat variable names containing underscores.
| .env Key | RF Variable | Type |
|---|---|---|
USER=value |
${user} |
Flat |
DB_HOST=value |
${db_host} |
Flat |
AUTHEN.USER=value |
${authen}[user] |
Nested dict |
DB.CONN.HOST=value |
${db}[conn][host] |
Deep nested dict |
Usage
YAML data files
# data/credentials.yaml
user: testuser
pass: "default_pass"
# data/config.yaml
db:
host: localhost
port: "5432"
.env file
# Flat overrides
USER=admin
PASS=S3cretK3y!
# Nested dict overrides (use dot separator)
DB.HOST=prod-db.example.com
DB.PORT=5433
Robot Framework test
*** Settings ***
Library EnvManageLibrary
Variables ${CURDIR}/data/credentials.yaml
Variables ${CURDIR}/data/config.yaml
*** Test Cases ***
Verify Credentials Override
Override Variables From Env path/to/.env
Should Be Equal ${user} admin
Should Be Equal ${pass} S3cretK3y!
Verify Config Override
Override Variables From Env path/to/.env
Should Be Equal ${db}[host] prod-db.example.com
Should Be Equal ${db}[port] 5433
Values Reset Between Tests
# No override called - original YAML values are intact
Should Be Equal ${user} testuser
Should Be Equal ${db}[host] localhost
How It Works
- Robot Framework loads YAML files via
Variables, creating RF variables Override Variables From Envparses the.envfile- For each RF variable, it checks for a matching
.envkey:- Flat string variables: YAML key
usermatches env keyUSER - Dict variables: YAML key
dbwith childhostmatches env keyDB.HOST
- Flat string variables: YAML key
- Matched values are overridden using
Set Test Variable(scoped to current test only) - Original YAML values remain intact for other test cases
Key Behaviors
- Override scope is per test case - original values reset between tests
- If
.envfile doesn't exist, all variables keep their YAML values - Case insensitive - YAML
usermatches envUSER - Flat keys with underscores (
DB_HOST) only override flat RF variables (${db_host}), not nested dicts - Dict values are deep-copied before override to prevent mutation
Development
git clone https://github.com/Non-Spk/robotframework-env-manage-library.git
cd robotframework-env-manage-library
python -m venv venv
# Windows
venv\Scripts\pip install -e ".[dev]"
venv\Scripts\pytest -v
# macOS / Linux
source venv/bin/activate
pip install -e ".[dev]"
pytest -v
Building
pip install build
python -m build
This produces dist/robotframework_env_manage-0.1.0-py3-none-any.whl and dist/robotframework_env_manage-0.1.0.tar.gz.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robotframework_env_manage_library-0.1.0.tar.gz.
File metadata
- Download URL: robotframework_env_manage_library-0.1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bed5e371d3f4bfea30036259f5dbf41908051fd289fecc8dd303eddb63981a1d
|
|
| MD5 |
904e29564c2f15cf38e28e27b656bd8d
|
|
| BLAKE2b-256 |
67082b28e936b1d82c406653e97e5eb353fc3237f5564af365afa42967590a21
|
Provenance
The following attestation bundles were made for robotframework_env_manage_library-0.1.0.tar.gz:
Publisher:
publish.yml on Non-Spk/robotframework-env-manage-library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
robotframework_env_manage_library-0.1.0.tar.gz -
Subject digest:
bed5e371d3f4bfea30036259f5dbf41908051fd289fecc8dd303eddb63981a1d - Sigstore transparency entry: 1191382403
- Sigstore integration time:
-
Permalink:
Non-Spk/robotframework-env-manage-library@4e65cef47914dca54a605e9b59e3603df40a6206 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Non-Spk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4e65cef47914dca54a605e9b59e3603df40a6206 -
Trigger Event:
release
-
Statement type:
File details
Details for the file robotframework_env_manage_library-0.1.0-py3-none-any.whl.
File metadata
- Download URL: robotframework_env_manage_library-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44e180924e7d362c70c7d0398795d5301646b16630994ce4d556d65b2ff6561b
|
|
| MD5 |
45b736615536b6faedda4dcb683a3431
|
|
| BLAKE2b-256 |
a7b50de5887f6e3e4b1e225c6d13e4db09889746a599ee16482b09cee47ad9f0
|
Provenance
The following attestation bundles were made for robotframework_env_manage_library-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Non-Spk/robotframework-env-manage-library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
robotframework_env_manage_library-0.1.0-py3-none-any.whl -
Subject digest:
44e180924e7d362c70c7d0398795d5301646b16630994ce4d556d65b2ff6561b - Sigstore transparency entry: 1191382406
- Sigstore integration time:
-
Permalink:
Non-Spk/robotframework-env-manage-library@4e65cef47914dca54a605e9b59e3603df40a6206 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Non-Spk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4e65cef47914dca54a605e9b59e3603df40a6206 -
Trigger Event:
release
-
Statement type: