Skip to main content

PyPI - License

TemplatedData

Introduction

TemplatedData is Robot Framework library for dynamically generated test data using robot variables and Jinja templating.

Requirements

Python 3.6+ and Robot Framework 3.2.1+.

TemplatedData will most likely work on other versions but it’s not tested on them.

Installation

You can install TemplateData by running:

pip install robotframework-templateddata

Usage

You need to import TemplatedData as library first:

*** Settings ***
Library    TemplatedData

TemplatedData will replace all occurences of robot variables (${var}) in file or variable using current robot context and scopes. All test data in below examples are saved under ‘test_data.txt’ files

Test data:

my variable is ${var}

Robot code:

${var}     Set Variable    ${10}
${data}    Get Templated Data From Path    test_data.txt
Log    ${data} # it should print `my variable is 10`

Default values

If the variable is not found it will be replaced with empty string. You can override that behaviour:

${data}    Get Templated Data From Path    test_data.txt    default_empty=${5}
Log    ${data} # it should print `my variable is 5`

You can also set default value of variable with : symbol.

Test data:

my variable is ${var} and ${var2:some string}

Robot code:

${var}     Set Variable    ${10}
${data}    Get Templated Data From Path    test_data.txt
Log    ${data} # it should print `my variable is 10 and some string`

Return value type

Return value can be either text/string (default) or json.

Test data:

{ "key": "${var}" }

Robot code:

${data}    Get Templated Data From Path    test_data.txt    var=value    return_type=json
Log    ${data} # it should print `{ "key": "value" }` and ${data} will be of type json

Jinja templating

TemplatedData can also render the Jinja templates using Robot Framework variables. To enable Jinja template pass jinja_template as argument to library import or method call:

 *** Settings ***
Library    TemplatedData  jinja_template=${True}

OR

*** Keywords ***
Load Data
    ${data}    Get Templated Data From Path    data.template    jinja_template=${True}

Test data (Jinja template):

{
    "accounts": [
        { "id": {{ ${account_id:5} }} },
        { "id2": "{{ ${account_id2} }}" }
        ],
    "users": [
{%- for user, amount in ${users.items()} %}
      {
        "name": "{{ user }}",
        "amount": {{ amount }}
      }{{ "," if not loop.last }}
{%- endfor %}
    ]
}

Robot code:

${data}    Get Templated Data From Path    data.template    jinja_template=${True}

Example data output:

 {
    "accounts": [
        { "id": 10 },
        { "id2": "10" }
        ],
    "users": [
      {
        "name": "bartek",
        "amount": 5
      },
      {
        "name": "tymoteusz",
        "amount": 10
      },
      {
        "name": "pawel",
        "amount": -1
      }
    ]
}

Metadata

Release files for robotframework-templateddata 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for robotframework-templateddata 1.4.0
File Size Uploaded Provenance
robotframework-templateddata-1.4.0.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for robotframework-templateddata 1.4.0
File Interpreter ABI Platform
robotframework_templateddata-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / robotframework-templateddata-1.4.0.tar.gz

Download URL robotframework-templateddata-1.4.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
53e1900b2a7bda62acdf324d38933e1bf44f6d63f6116397cebeab7feeb3c92b
BLAKE2b-256 checksum
How to use checksums
7f607380b083186472b6c5c64ef5ac0858c3e048a9bd3c32051e7976d3fdf9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / robotframework_templateddata-1.4.0-py3-none-any.whl

Download URL robotframework_templateddata-1.4.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bdbfe9a84f42b0911eef48dd2a5ec7e64e5cac89a8c78471ae58216994a55f6
BLAKE2b-256 checksum
How to use checksums
693f2dff73100aa546b282fd51c5cda4abaadb5875aba5218d6c262c2af913bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for robotframework-templateddata 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page