sat-unittest-dataprovider


Namesat-unittest-dataprovider JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://gitlab.com/markus2110-public/python/packages/unittest-dataprovider
SummaryPackage to add a data_provider decorator to a function, to run the test with different values
upload_time2024-03-10 19:02:10
maintainer
docs_urlNone
authorMarkus
requires_python>=3.8,<3.13
license
keywords test testing unittest unit test data provider dataprovider test cases
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Unittest dataprovider



[![coverage report](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/badges/develop/coverage.svg)](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/-/commits/develop)
[![pipeline status](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/badges/develop/pipeline.svg)](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/-/commits/develop) 

## Description
Python package to add a `data_provider` decorator to a test function,   
to execute the test with different test values / cases.    
The test function will be executed for each record, which is defined at the `data_provider`.
```python
@data_provider([                    # The DataSet as a List
    (value1, value2, value3),       # Record 1
    (value1, value2, value3)        # Record 2    
    (value1, value2, value3)        # Record 3    
])
```
The data_provider accepts the following Types as argument
- Function
- Dict
- List
- Tuple

> This package is a Python version of the PHP UnitTest dataprovider.   
> https://phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers


## Installation
```commandline
pip install sat_unittest_dataprovider
```
or
```commandline
python -m pip install sat_unittest_dataprovider
```

## Usage

> The test method will be called with the values of the record as arguments   
> **Therefor you need to make sure, to define the same amount of arguments at the test function,**  
> **as you defined values at the record.**
> ```python
> @data_provider([
>     (arg1, arg2, arg3, arg4) 
> ])
> def test_multiply(arg1, arg2, arg3, arg4):
>     ...
>     do someting the arguments
>     ...
> ```

> Without the unittest data provider you would probably create a test like this:
> ```python
> class Test(TestCase):
>     def test_without_dataprovider(self):
>         test_data = [
>             (1, 1, '1 * 1 is 1'),
>             (2, 4, '2 * 2 is 4')
>         ]
>         for row in test_data:
>             given_value, expected_result, msg = row                     # We unpack the tuple here
>             calculated_result = given_value * given_value               # Calculation
>             self.assertEqual(expected_result, calculated_result, msg)   # The Test   
>
>```
 
> The same test with the data_provider decorator would look like this:
> ```python
> class Test(TestCase):
>     @data_provider([
>         (1, 1, '1 * 1 is 1'),
>         (2, 4, '2 * 2 is 4')
>     ])
>     def test_with_dataprovider(self, given_value, expected_result, msg):    # We get all values as function arguments
>         calculated_result = given_value * given_value                       # Calculation
>         self.assertEqual(expected_result, calculated_result, msg)           # The Test
> ```
> This makes the test more readable to others.
***
Simple example:
```python
@data_provider([
    (1, 2, 3, '1 + 2 = 3') 
])
def test_simple_example(self, value, value2, expected, msg):
    self.assertEqual(expected, value + value2, msg)
```
> At the example above, we define 4 values at the record, we want to test a simple number addition.   
> The first argument `value` will be added to the second argument `value2` and we expect,   
> that the calculated result is the same as defined in `expected`.   
> The last argument `msg` is used as a message which will be shown, when the test fails.
***
Example 1:
`DataSet is a List of Tupels`
```python
from unittest import TestCase
from sat_unittest_dataprovider import data_provider

class Test(TestCase):
    
    @data_provider([
        (1, 1, '1 * 1 is 1'), 
        (2, 4, '2 * 2 is 4'),
        (3, 9, '3 * 3 is 9')
    ])
    def test_multiply(self, given, expected, message):
        calculated_result = given * given
        self.assertEqual(expected, calculated_result, message)
```
***
Example 2:
`DataSet is a List with List items`
```python
from unittest import TestCase
from sat_unittest_dataprovider import data_provider

class Test(TestCase):
    
    @data_provider([
        [1, 1, '1 * 1 is 1'], 
        [2, 4, '2 * 2 is 4'],
        [3, 9, '3 * 3 is 9']
    ])
    def test_multiply(self, given, expected, message):
        calculated_result = given * given
        self.assertEqual(expected, calculated_result, message)
```
***
Example 3:
`DataSet is a Function, which should return the test records either as List, Dict or Tuple`    
```python
from unittest import TestCase
from sat_unittest_dataprovider import data_provider

def my_data_set():
    return [
        [1, 1, '1 * 1 is 1'], 
        [2, 4, '2 * 2 is 4'],
        [3, 9, '3 * 3 is 9']
    ] 

class Test(TestCase):
    
    @data_provider(my_data_set)
    def test_multiply(self, given, expected, message):
        calculated_result = given * given
        self.assertEqual(expected, calculated_result, message)

    @data_provider(my_data_set)
    def test_divider(self, divider, given, message):
        expected_result = divider                               # the expected result is the same as the divider
        calculated_result = given / divider
        self.assertEqual(expected_result, calculated_result)    # We don't use the message here, because for this test it doesn't make sense ;-)
```
> In the example above, you can use the data_set function for multiple test cases   
> to reduce code duplication
***
Example 4:
`DataSet is a seperate file`
> For bigger tests you can place the provider functions or values in a separate file   
> 
`test/data_providers.py`
```python
 def tuples_in_list() -> list[tuple[int, int, int, str]]:
    return [
        (1, 2, 3, '1 + 2 is 3'),
        (2, 2, 4, '2 + 2 is 3')
    ]


def tuples_in_tuple() -> tuple[tuple[int, int, int, str], ...]:
    return (
        (1, 2, 3, '1 + 2 is 3'),
        (2, 2, 4, '2 + 2 is 3'),
    )


def dict_with_tuples() -> dict[str, tuple[int, int, int, str]]:
    return {
        "record_1": (1, 2, 3, '1 + 2 is 3'),
        "record_2": (2, 2, 4, '2 + 2 is 3'),
    }


a_dict: dict[str, tuple[int, int, int, str]] = {
        "record_1": (1, 2, 3, '1 + 2 is 3'),
        "record_2": (2, 2, 4, '2 + 2 is 3'),
    }
```

`test/test_readme_examples.py`
```python
from unittest import TestCase
from sat_unittest_dataprovider import data_provider

from .data_providers import (
    tuples_in_list,
    tuples_in_tuple,
    dict_with_tuples,
    a_dict
)


class Test(TestCase):

    @data_provider(tuples_in_list)
    def test_addition_with_tuples_in_list(self, value1, value2, expected, msg):
        self.assertEqual(expected, value1 + value2, msg)

    @data_provider(tuples_in_tuple)
    def test_addition_with_tuples_in_tuple(self, value1, value2, expected, msg):
        self.assertEqual(expected, value1 + value2, msg)

    @data_provider(dict_with_tuples)
    def test_addition_with_dict_with_tuples(self, value1, value2, expected, msg):
        self.assertEqual(expected, value1 + value2, msg)

    @data_provider(a_dict)
    def test_addition_with_a_dict(self, value1, value2, expected, msg):
        self.assertEqual(expected, value1 + value2, msg)    

```
*** 
## Example
We have function, which will convert a `snake_case` value to an `camelCase` value.
The function looks like this

```python
'tests/real_world_example.py'

def snake_case_to_camel_case(snake_case_value: str, first_to_upper: bool = False) -> str:
    """
    This function converts a given snake_case value to an camelCase, 
    optionally you could set first_to_upper = True to return a string where the first 
    letter is upper case as well ( camel_case => CamelCase )
     
    :param snake_case_value: The snake case value
    :param first_to_upper: If True, the first letter of the first item will be uppercase as well
    :return: The camelCase string
    """
    snake_case_items = snake_case_value.split("_")  # we split the value at each `_` underscore
    camel_case_items: list = list()                 # a list to store the converted items

    for index, item in enumerate(snake_case_items):

        first_letter = item[:1]     # we get the first letter of the item
        the_rest = item[1:]         # we get the rest of the string, excluding the first letter

        # make sure the first item is lower case
        if first_to_upper is False and index == 0:
            camel_case_items.append(first_letter.lower() + the_rest)
        else:
            camel_case_items.append(first_letter.upper() + the_rest)

    return "".join(camel_case_items)
```
The unit test would look like this.    
We define 14 Test cases, within the data_provider decorator
```python
    @data_provider([
        # The snake case value  | First item upper | The Expected Result     | The failure message
        ("some_camel_case_string",      True,       "SomeCamelCaseString",      "Test Case 1, first item upper"),
        ("this_is_Another_string",      True,       "ThisIsAnotherString",      "Test Case 2, first item upper"),
        ("ThisIsAlreadyCamelCase",      True,       "ThisIsAlreadyCamelCase",   "Test Case 3, first item upper"),
        ("This_is_an_other_Test",       True,       "ThisIsAnOtherTest",        "Test Case 4, first item upper"),
        ("This_is_an_OtHer_Test",       True,       "ThisIsAnOtHerTest",        "Test Case 5, first item upper"),
        ("a_b_c_d_e_f_g_h_i_j_k",       True,       "ABCDEFGHIJK",              "Test Case 6, first item upper"),
        ("test_with_2_numbers_1_and_2", True,       "TestWith2Numbers1And2",    "Test Case 7, first item upper"),

        # No we run the same test, but this time, the first item should be lower case
        ("some_camel_case_string",      False,      "someCamelCaseString",      "Test Case 8, first item lower"),
        ("this_is_Another_string",      False,      "thisIsAnotherString",      "Test Case 9, first item lower"),
        ("ThisIsAlreadyCamelCase",      False,      "thisIsAlreadyCamelCase",   "Test Case 10, first item lower"),
        ("This_is_an_other_Test",       False,      "thisIsAnOtherTest",        "Test Case 11, first item lower"),
        ("This_is_an_OtHer_Test",       False,      "thisIsAnOtHerTest",        "Test Case 12, first item lower"),
        ("a_b_c_d_e_f_g_h_i_j_k",       False,      "aBCDEFGHIJK",              "Test Case 13, first item lower"),
        ("test_with_2_numbers_1_and_2", False,      "testWith2Numbers1And2",    "Test Case 14, first item lower")
    ])
```
The first half of the test cases are designed to test that the result should return a converted value,   
where the first letter is upper case as well. 
```python
(
    "some_camel_case_string",           # The snake case value       
    True,                               # First letter should be upper case as well
    "SomeCamelCaseString",              # The Expected Result
    "Test Case 1, first item upper"     # The failure message
),
...
```
The second half will test, that the result should return a converted value, where the first letter is lower case.
```python
(
    "some_camel_case_string",           # The snake case value       
    False,                              # First letter should not be upper case
    "someCamelCaseString",              # The Expected Result
    "Test Case8, first item lower"     # The failure message
),
```
***
```python
'tests/test_readme_examples.py'

from unittest import TestCase
from sat_unittest_dataprovider import data_provider
from .real_world_example import snake_case_to_camel_case


class Test(TestCase):
    
    @data_provider([
        # The snake case value  | First item upper | The Expected Result     | The failure message
        ("some_camel_case_string",      True,       "SomeCamelCaseString",      "Test Case 1, first item upper"),
        ("this_is_Another_string",      True,       "ThisIsAnotherString",      "Test Case 2, first item upper"),
        ("ThisIsAlreadyCamelCase",      True,       "ThisIsAlreadyCamelCase",   "Test Case 3, first item upper"),
        ("This_is_an_other_Test",       True,       "ThisIsAnOtherTest",        "Test Case 4, first item upper"),
        ("This_is_an_OtHer_Test",       True,       "ThisIsAnOtHerTest",        "Test Case 5, first item upper"),
        ("a_b_c_d_e_f_g_h_i_j_k",       True,       "ABCDEFGHIJK",              "Test Case 6, first item upper"),
        ("test_with_2_numbers_1_and_2", True,       "TestWith2Numbers1And2",    "Test Case 7, first item upper"),

        # No we run the same test, but this time, the first item should be lower case
        ("some_camel_case_string",      False,      "someCamelCaseString",      "Test Case 8, first item lower"),
        ("this_is_Another_string",      False,      "thisIsAnotherString",      "Test Case 9, first item lower"),
        ("ThisIsAlreadyCamelCase",      False,      "thisIsAlreadyCamelCase",   "Test Case 10, first item lower"),
        ("This_is_an_other_Test",       False,      "thisIsAnOtherTest",        "Test Case 11, first item lower"),
        ("This_is_an_OtHer_Test",       False,      "thisIsAnOtHerTest",        "Test Case 12, first item lower"),
        ("a_b_c_d_e_f_g_h_i_j_k",       False,      "aBCDEFGHIJK",              "Test Case 13, first item lower"),
        ("test_with_2_numbers_1_and_2", False,      "testWith2Numbers1And2",    "Test Case 14, first item lower")
    ])
    def test_snake_case_to_camel_case(self, given_value, first_item_upper, expected_value, msg):
        camel_case: str = snake_case_to_camel_case(given_value, first_item_upper)
        self.assertEqual(expected_value, camel_case, msg)    
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider",
    "name": "sat-unittest-dataprovider",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<3.13",
    "maintainer_email": "",
    "keywords": "test,testing,unittest,unit test,data provider,dataprovider,test cases",
    "author": "Markus",
    "author_email": "markus2110@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/87/13/fb8e5bf76c4c25f87917c7b1dd682648cfb8e0c4cf8a046ab037c4eb1411/sat_unittest_dataprovider-1.0.0.tar.gz",
    "platform": null,
    "description": "# Python Unittest dataprovider\n\n\n\n[![coverage report](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/badges/develop/coverage.svg)](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/-/commits/develop)\n[![pipeline status](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/badges/develop/pipeline.svg)](https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider/-/commits/develop) \n\n## Description\nPython package to add a `data_provider` decorator to a test function,   \nto execute the test with different test values / cases.    \nThe test function will be executed for each record, which is defined at the `data_provider`.\n```python\n@data_provider([                    # The DataSet as a List\n    (value1, value2, value3),       # Record 1\n    (value1, value2, value3)        # Record 2    \n    (value1, value2, value3)        # Record 3    \n])\n```\nThe data_provider accepts the following Types as argument\n- Function\n- Dict\n- List\n- Tuple\n\n> This package is a Python version of the PHP UnitTest dataprovider.   \n> https://phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers\n\n\n## Installation\n```commandline\npip install sat_unittest_dataprovider\n```\nor\n```commandline\npython -m pip install sat_unittest_dataprovider\n```\n\n## Usage\n\n> The test method will be called with the values of the record as arguments   \n> **Therefor you need to make sure, to define the same amount of arguments at the test function,**  \n> **as you defined values at the record.**\n> ```python\n> @data_provider([\n>     (arg1, arg2, arg3, arg4) \n> ])\n> def test_multiply(arg1, arg2, arg3, arg4):\n>     ...\n>     do someting the arguments\n>     ...\n> ```\n\n> Without the unittest data provider you would probably create a test like this:\n> ```python\n> class Test(TestCase):\n>     def test_without_dataprovider(self):\n>         test_data = [\n>             (1, 1, '1 * 1 is 1'),\n>             (2, 4, '2 * 2 is 4')\n>         ]\n>         for row in test_data:\n>             given_value, expected_result, msg = row                     # We unpack the tuple here\n>             calculated_result = given_value * given_value               # Calculation\n>             self.assertEqual(expected_result, calculated_result, msg)   # The Test   \n>\n>```\n \n> The same test with the data_provider decorator would look like this:\n> ```python\n> class Test(TestCase):\n>     @data_provider([\n>         (1, 1, '1 * 1 is 1'),\n>         (2, 4, '2 * 2 is 4')\n>     ])\n>     def test_with_dataprovider(self, given_value, expected_result, msg):    # We get all values as function arguments\n>         calculated_result = given_value * given_value                       # Calculation\n>         self.assertEqual(expected_result, calculated_result, msg)           # The Test\n> ```\n> This makes the test more readable to others.\n***\nSimple example:\n```python\n@data_provider([\n    (1, 2, 3, '1 + 2 = 3') \n])\ndef test_simple_example(self, value, value2, expected, msg):\n    self.assertEqual(expected, value + value2, msg)\n```\n> At the example above, we define 4 values at the record, we want to test a simple number addition.   \n> The first argument `value` will be added to the second argument `value2` and we expect,   \n> that the calculated result is the same as defined in `expected`.   \n> The last argument `msg` is used as a message which will be shown, when the test fails.\n***\nExample 1:\n`DataSet is a List of Tupels`\n```python\nfrom unittest import TestCase\nfrom sat_unittest_dataprovider import data_provider\n\nclass Test(TestCase):\n    \n    @data_provider([\n        (1, 1, '1 * 1 is 1'), \n        (2, 4, '2 * 2 is 4'),\n        (3, 9, '3 * 3 is 9')\n    ])\n    def test_multiply(self, given, expected, message):\n        calculated_result = given * given\n        self.assertEqual(expected, calculated_result, message)\n```\n***\nExample 2:\n`DataSet is a List with List items`\n```python\nfrom unittest import TestCase\nfrom sat_unittest_dataprovider import data_provider\n\nclass Test(TestCase):\n    \n    @data_provider([\n        [1, 1, '1 * 1 is 1'], \n        [2, 4, '2 * 2 is 4'],\n        [3, 9, '3 * 3 is 9']\n    ])\n    def test_multiply(self, given, expected, message):\n        calculated_result = given * given\n        self.assertEqual(expected, calculated_result, message)\n```\n***\nExample 3:\n`DataSet is a Function, which should return the test records either as List, Dict or Tuple`    \n```python\nfrom unittest import TestCase\nfrom sat_unittest_dataprovider import data_provider\n\ndef my_data_set():\n    return [\n        [1, 1, '1 * 1 is 1'], \n        [2, 4, '2 * 2 is 4'],\n        [3, 9, '3 * 3 is 9']\n    ] \n\nclass Test(TestCase):\n    \n    @data_provider(my_data_set)\n    def test_multiply(self, given, expected, message):\n        calculated_result = given * given\n        self.assertEqual(expected, calculated_result, message)\n\n    @data_provider(my_data_set)\n    def test_divider(self, divider, given, message):\n        expected_result = divider                               # the expected result is the same as the divider\n        calculated_result = given / divider\n        self.assertEqual(expected_result, calculated_result)    # We don't use the message here, because for this test it doesn't make sense ;-)\n```\n> In the example above, you can use the data_set function for multiple test cases   \n> to reduce code duplication\n***\nExample 4:\n`DataSet is a seperate file`\n> For bigger tests you can place the provider functions or values in a separate file   \n> \n`test/data_providers.py`\n```python\n def tuples_in_list() -> list[tuple[int, int, int, str]]:\n    return [\n        (1, 2, 3, '1 + 2 is 3'),\n        (2, 2, 4, '2 + 2 is 3')\n    ]\n\n\ndef tuples_in_tuple() -> tuple[tuple[int, int, int, str], ...]:\n    return (\n        (1, 2, 3, '1 + 2 is 3'),\n        (2, 2, 4, '2 + 2 is 3'),\n    )\n\n\ndef dict_with_tuples() -> dict[str, tuple[int, int, int, str]]:\n    return {\n        \"record_1\": (1, 2, 3, '1 + 2 is 3'),\n        \"record_2\": (2, 2, 4, '2 + 2 is 3'),\n    }\n\n\na_dict: dict[str, tuple[int, int, int, str]] = {\n        \"record_1\": (1, 2, 3, '1 + 2 is 3'),\n        \"record_2\": (2, 2, 4, '2 + 2 is 3'),\n    }\n```\n\n`test/test_readme_examples.py`\n```python\nfrom unittest import TestCase\nfrom sat_unittest_dataprovider import data_provider\n\nfrom .data_providers import (\n    tuples_in_list,\n    tuples_in_tuple,\n    dict_with_tuples,\n    a_dict\n)\n\n\nclass Test(TestCase):\n\n    @data_provider(tuples_in_list)\n    def test_addition_with_tuples_in_list(self, value1, value2, expected, msg):\n        self.assertEqual(expected, value1 + value2, msg)\n\n    @data_provider(tuples_in_tuple)\n    def test_addition_with_tuples_in_tuple(self, value1, value2, expected, msg):\n        self.assertEqual(expected, value1 + value2, msg)\n\n    @data_provider(dict_with_tuples)\n    def test_addition_with_dict_with_tuples(self, value1, value2, expected, msg):\n        self.assertEqual(expected, value1 + value2, msg)\n\n    @data_provider(a_dict)\n    def test_addition_with_a_dict(self, value1, value2, expected, msg):\n        self.assertEqual(expected, value1 + value2, msg)    \n\n```\n*** \n## Example\nWe have function, which will convert a `snake_case` value to an `camelCase` value.\nThe function looks like this\n\n```python\n'tests/real_world_example.py'\n\ndef snake_case_to_camel_case(snake_case_value: str, first_to_upper: bool = False) -> str:\n    \"\"\"\n    This function converts a given snake_case value to an camelCase, \n    optionally you could set first_to_upper = True to return a string where the first \n    letter is upper case as well ( camel_case => CamelCase )\n     \n    :param snake_case_value: The snake case value\n    :param first_to_upper: If True, the first letter of the first item will be uppercase as well\n    :return: The camelCase string\n    \"\"\"\n    snake_case_items = snake_case_value.split(\"_\")  # we split the value at each `_` underscore\n    camel_case_items: list = list()                 # a list to store the converted items\n\n    for index, item in enumerate(snake_case_items):\n\n        first_letter = item[:1]     # we get the first letter of the item\n        the_rest = item[1:]         # we get the rest of the string, excluding the first letter\n\n        # make sure the first item is lower case\n        if first_to_upper is False and index == 0:\n            camel_case_items.append(first_letter.lower() + the_rest)\n        else:\n            camel_case_items.append(first_letter.upper() + the_rest)\n\n    return \"\".join(camel_case_items)\n```\nThe unit test would look like this.    \nWe define 14 Test cases, within the data_provider decorator\n```python\n    @data_provider([\n        # The snake case value  | First item upper | The Expected Result     | The failure message\n        (\"some_camel_case_string\",      True,       \"SomeCamelCaseString\",      \"Test Case 1, first item upper\"),\n        (\"this_is_Another_string\",      True,       \"ThisIsAnotherString\",      \"Test Case 2, first item upper\"),\n        (\"ThisIsAlreadyCamelCase\",      True,       \"ThisIsAlreadyCamelCase\",   \"Test Case 3, first item upper\"),\n        (\"This_is_an_other_Test\",       True,       \"ThisIsAnOtherTest\",        \"Test Case 4, first item upper\"),\n        (\"This_is_an_OtHer_Test\",       True,       \"ThisIsAnOtHerTest\",        \"Test Case 5, first item upper\"),\n        (\"a_b_c_d_e_f_g_h_i_j_k\",       True,       \"ABCDEFGHIJK\",              \"Test Case 6, first item upper\"),\n        (\"test_with_2_numbers_1_and_2\", True,       \"TestWith2Numbers1And2\",    \"Test Case 7, first item upper\"),\n\n        # No we run the same test, but this time, the first item should be lower case\n        (\"some_camel_case_string\",      False,      \"someCamelCaseString\",      \"Test Case 8, first item lower\"),\n        (\"this_is_Another_string\",      False,      \"thisIsAnotherString\",      \"Test Case 9, first item lower\"),\n        (\"ThisIsAlreadyCamelCase\",      False,      \"thisIsAlreadyCamelCase\",   \"Test Case 10, first item lower\"),\n        (\"This_is_an_other_Test\",       False,      \"thisIsAnOtherTest\",        \"Test Case 11, first item lower\"),\n        (\"This_is_an_OtHer_Test\",       False,      \"thisIsAnOtHerTest\",        \"Test Case 12, first item lower\"),\n        (\"a_b_c_d_e_f_g_h_i_j_k\",       False,      \"aBCDEFGHIJK\",              \"Test Case 13, first item lower\"),\n        (\"test_with_2_numbers_1_and_2\", False,      \"testWith2Numbers1And2\",    \"Test Case 14, first item lower\")\n    ])\n```\nThe first half of the test cases are designed to test that the result should return a converted value,   \nwhere the first letter is upper case as well. \n```python\n(\n    \"some_camel_case_string\",           # The snake case value       \n    True,                               # First letter should be upper case as well\n    \"SomeCamelCaseString\",              # The Expected Result\n    \"Test Case 1, first item upper\"     # The failure message\n),\n...\n```\nThe second half will test, that the result should return a converted value, where the first letter is lower case.\n```python\n(\n    \"some_camel_case_string\",           # The snake case value       \n    False,                              # First letter should not be upper case\n    \"someCamelCaseString\",              # The Expected Result\n    \"Test Case8, first item lower\"     # The failure message\n),\n```\n***\n```python\n'tests/test_readme_examples.py'\n\nfrom unittest import TestCase\nfrom sat_unittest_dataprovider import data_provider\nfrom .real_world_example import snake_case_to_camel_case\n\n\nclass Test(TestCase):\n    \n    @data_provider([\n        # The snake case value  | First item upper | The Expected Result     | The failure message\n        (\"some_camel_case_string\",      True,       \"SomeCamelCaseString\",      \"Test Case 1, first item upper\"),\n        (\"this_is_Another_string\",      True,       \"ThisIsAnotherString\",      \"Test Case 2, first item upper\"),\n        (\"ThisIsAlreadyCamelCase\",      True,       \"ThisIsAlreadyCamelCase\",   \"Test Case 3, first item upper\"),\n        (\"This_is_an_other_Test\",       True,       \"ThisIsAnOtherTest\",        \"Test Case 4, first item upper\"),\n        (\"This_is_an_OtHer_Test\",       True,       \"ThisIsAnOtHerTest\",        \"Test Case 5, first item upper\"),\n        (\"a_b_c_d_e_f_g_h_i_j_k\",       True,       \"ABCDEFGHIJK\",              \"Test Case 6, first item upper\"),\n        (\"test_with_2_numbers_1_and_2\", True,       \"TestWith2Numbers1And2\",    \"Test Case 7, first item upper\"),\n\n        # No we run the same test, but this time, the first item should be lower case\n        (\"some_camel_case_string\",      False,      \"someCamelCaseString\",      \"Test Case 8, first item lower\"),\n        (\"this_is_Another_string\",      False,      \"thisIsAnotherString\",      \"Test Case 9, first item lower\"),\n        (\"ThisIsAlreadyCamelCase\",      False,      \"thisIsAlreadyCamelCase\",   \"Test Case 10, first item lower\"),\n        (\"This_is_an_other_Test\",       False,      \"thisIsAnOtherTest\",        \"Test Case 11, first item lower\"),\n        (\"This_is_an_OtHer_Test\",       False,      \"thisIsAnOtHerTest\",        \"Test Case 12, first item lower\"),\n        (\"a_b_c_d_e_f_g_h_i_j_k\",       False,      \"aBCDEFGHIJK\",              \"Test Case 13, first item lower\"),\n        (\"test_with_2_numbers_1_and_2\", False,      \"testWith2Numbers1And2\",    \"Test Case 14, first item lower\")\n    ])\n    def test_snake_case_to_camel_case(self, given_value, first_item_upper, expected_value, msg):\n        camel_case: str = snake_case_to_camel_case(given_value, first_item_upper)\n        self.assertEqual(expected_value, camel_case, msg)    \n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Package to add a data_provider decorator to a function, to run the test with different values",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/markus2110-public/python/packages/unittest-dataprovider"
    },
    "split_keywords": [
        "test",
        "testing",
        "unittest",
        "unit test",
        "data provider",
        "dataprovider",
        "test cases"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "667564ef2ae2e1b8c4c52cffedb882994453b048f68af60b02ade7859d11c100",
                "md5": "457771c721eef4f123f12b67235ee169",
                "sha256": "2da3c41fd3e67878b7304ef14d3e0554e0718ccb6872ab8dc7b5ede184ba7ed7"
            },
            "downloads": -1,
            "filename": "sat_unittest_dataprovider-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "457771c721eef4f123f12b67235ee169",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<3.13",
            "size": 8400,
            "upload_time": "2024-03-10T19:02:08",
            "upload_time_iso_8601": "2024-03-10T19:02:08.681187Z",
            "url": "https://files.pythonhosted.org/packages/66/75/64ef2ae2e1b8c4c52cffedb882994453b048f68af60b02ade7859d11c100/sat_unittest_dataprovider-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8713fb8e5bf76c4c25f87917c7b1dd682648cfb8e0c4cf8a046ab037c4eb1411",
                "md5": "70afe2b5a0e2e24bacf61a2c763d51a9",
                "sha256": "091f05c7a909fb11509eb09df92f03f17c3b08ee4b7132a32a8151e458d26e95"
            },
            "downloads": -1,
            "filename": "sat_unittest_dataprovider-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "70afe2b5a0e2e24bacf61a2c763d51a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<3.13",
            "size": 7435,
            "upload_time": "2024-03-10T19:02:10",
            "upload_time_iso_8601": "2024-03-10T19:02:10.352906Z",
            "url": "https://files.pythonhosted.org/packages/87/13/fb8e5bf76c4c25f87917c7b1dd682648cfb8e0c4cf8a046ab037c4eb1411/sat_unittest_dataprovider-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-10 19:02:10",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "markus2110-public",
    "gitlab_project": "python",
    "lcname": "sat-unittest-dataprovider"
}
        
Elapsed time: 0.20379s