Creating a library to check various types of a variable by ferrarigian · Pull Request #5033 · robotframework/robotframework · GitHub
Skip to content

Creating a library to check various types of a variable#5033

Open
ferrarigian wants to merge 1 commit into
robotframework:masterfrom
ferrarigian:tunning-check-variables-type
Open

Creating a library to check various types of a variable#5033
ferrarigian wants to merge 1 commit into
robotframework:masterfrom
ferrarigian:tunning-check-variables-type

Conversation

@ferrarigian

Copy link
Copy Markdown

Library Name: CheckType

The CheckType library is designed to provide a set of validation functions for checking the data types of Python objects. This library is particularly useful within the Robot Framework, offering a straightforward way to assert and validate the types of variables.

Key Features:

  1. Type Checking Functions:

    • The library includes a collection of functions to check if a given item is of a specific data type. Supported types include dictionaries, objects, integers, lists, booleans, floats, NoneType, tuples, and sets.
  2. Customizable Error Messages:

    • Each type-checking function allows the user to include a custom error message. This feature enhances flexibility, enabling users to provide meaningful context in case of a type mismatch.
  3. Negation Functions:

    • In addition to type-checking functions, the library provides corresponding functions to assert that an item is not of a certain type. This enables users to perform comprehensive type validation in their Robot Framework test cases.

Example Usage:

*** Settings ***
Library    CheckType

*** Test Cases ***
Validate Dictionary Type
    ${data}=    Create Dictionary    key=value
    CheckType.Should Be Dictionary    ${data}    msg=Expected a dictionary, but got ${data}

Ensure Not a List
    ${value}=   Set Variable    SomeValue
    CheckType.Should Not Be List    ${value}    msg=${value} should not be a list

@franzhaas

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants