Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ferrarigian
Copy link

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
Contributor

Hi ferrarigian,

Have you considered putting this library with examples and tests onto the marketquare? and PyPI?

Do you think this could be a good alternative to merging it into core?

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