py-artest


Namepy-artest JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/HYChou0515/py-artest
SummaryAutomated Regression Testing Framework for Python
upload_time2023-12-05 04:59:58
maintainer
docs_urlNone
authorChou Hung-Yi
requires_python>=3.8
licenseMIT
keywords regression-testing automated-testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Artest: Auto Regression Test


Imagine you have a software program, and you want to create a regression test case for a specific function within it. 
πŸ”¬ To achieve this, it's best to simulate real-life scenarios. 
🌍 This is where Artest, a useful tool, comes into play. 
Artest automates the process of generating test cases while your program is running. 
πŸ€– These test cases are then stored in a designated directory. 
πŸ“‚ When you make future modifications to your program, 
you can rely on the previously generated test cases to ensure that everything continues to work smoothly. 
πŸ‘Œ This approach safeguards the stability and dependability of 
your program by preventing unexpected issues and accidental breakdowns. πŸš€

## Installation

You can install Artest using pip:

```bash
pip install py-artest
```

This will install Artest and its dependencies. 
Optionally, if you require the 'dill' package for additional functionality, 
you can install it as follows:

```bash
pip install py-artest[dill]
```

## Tutorial

You can find a detailed tutorial on how to use Artest in the following articles:

- [Simplifying Regression Testing in Python with PyArtest’s Decorators](https://hychou-svm.medium.com/simplifying-regression-testing-in-python-with-pyartests-decorators-f18b33eacb04)
- [Gist Sample Code](https://gist.github.com/HYChou0515/2fbed4f4aa9f57a9344ffbeb2326b121)


## Advantages 


- Automation πŸ€–: Artest automates the process of generating test cases for your software program while it is running, saving you time and effort in creating them manually.
- Real-life Scenarios 🌟: Artest allows you to simulate real-life scenarios for regression testing, enabling you to validate your program's behavior in a more realistic context.
- Test Case Storage πŸ“‚: Artest stores the generated test cases in a designated directory, making it easy to access and manage them.
- Regression Testing πŸ‘¨β€πŸ’»: By relying on previously generated test cases, Artest enables you to perform regression testing. This means you can run the tests after making future modifications to ensure that the program continues to function correctly, catching any unexpected issues or breakdowns.
- Stability and Dependability πŸš€: Utilizing Artest's generated test cases helps safeguard the stability and dependability of your program. By identifying and preventing issues early on, it ensures that your program remains reliable and performs as expected.

## Basic use case: autoreg

Let's consider a program written in Python:


```python
def hello(say):
    to = to_whom(1)
    return f"{say} {to}!"

def to_whom(x):
    choices = read_from_db()
    # choices = ["sir", "world",]
    return choices[x]

if __name__ == "__main__":
    print(hello("hello"))
    # Output: hello world!
```

In this program, you only need to add a decorator called autoreg to the hello function:

```python
from artest import autoreg

@autoreg("a5f4cb0f")  # πŸŽ‰ add this to auto create test case
def hello(say):
    to = to_whom(1)
    return f"{say} {to}!"

def to_whom(x):
    choices = read_from_db()
    # choices = ["sir", "world",]
    return choices[x]

if __name__ == "__main__":
    print(hello("hello"))
    # Output: hello world!
```

By applying the autoreg decorator, 
you enable the creation of a test case associated with the 
unique function id `a5f4cb0f`
whenever the hello function is called.
The test case generation is done automatically.
In this updated version, we still have the to_whom function to determine the value of to.
When running the program, the output remains the same: "hello world!".

## Stubbing with autostub
In situations where the to_whom function takes a long time to execute or is not available during testing, you can create a stub instead. A stub is a simulated function that returns predefined values specifically defined in the test case.

To automatically create a stub, you can use the autostub decorator. When applied to a function, Artest will generate the stub for you.

```python
from artest import autoreg, autostub

@autoreg("a5f4cb0f")
def hello(say):
    to = to_whom(1)
    return f"{say} {to}!"

@autostub("35988d25")  # πŸŽ‰ add this to auto create stub function
def to_whom(x):
    choices = read_from_db()
    # choices = ["sir", "world",]
    return choices[x]

if __name__ == "__main__":
    print(hello("hello"))
    # Output: hello world!
```

In the updated code, the to_whom function has been decorated with autostub 
using the unique identifier "35988d25". 
This allows Artest to automatically generate a stub for the to_whom function. 
Inside the stub, the choices variable is typically defined in the test case 
rather than being fetched from the database, 
ensuring faster and more controlled testing.

When running the program, the output remains the same: "hello world!".


## Test with artest

Once artest is installed, you can run it in test mode using the command:

```bash
python -m artest
```

This command executes artest in test mode, 
allowing the framework to manage and execute the defined test cases 
based on the configured environment. 
Running artest in test mode enables the verification and 
validation of your program's behavior against the predefined test cases, 
ensuring that the functionality operates as expected 
and remains stable even after modifications.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/HYChou0515/py-artest",
    "name": "py-artest",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "regression-testing,automated-testing",
    "author": "Chou Hung-Yi",
    "author_email": "hychou.svm@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9c/01/890a4ae3e03a7ba042c4937c7f913d20c6f4bda60de01dcf66da582aa39e/py_artest-0.3.0.tar.gz",
    "platform": null,
    "description": "# Artest: Auto Regression Test\n\n\nImagine you have a software program, and you want to create a regression test case for a specific function within it. \n\ud83d\udd2c To achieve this, it's best to simulate real-life scenarios. \n\ud83c\udf0d This is where Artest, a useful tool, comes into play. \nArtest automates the process of generating test cases while your program is running. \n\ud83e\udd16 These test cases are then stored in a designated directory. \n\ud83d\udcc2 When you make future modifications to your program, \nyou can rely on the previously generated test cases to ensure that everything continues to work smoothly. \n\ud83d\udc4c This approach safeguards the stability and dependability of \nyour program by preventing unexpected issues and accidental breakdowns. \ud83d\ude80\n\n## Installation\n\nYou can install Artest using pip:\n\n```bash\npip install py-artest\n```\n\nThis will install Artest and its dependencies. \nOptionally, if you require the 'dill' package for additional functionality, \nyou can install it as follows:\n\n```bash\npip install py-artest[dill]\n```\n\n## Tutorial\n\nYou can find a detailed tutorial on how to use Artest in the following articles:\n\n- [Simplifying Regression Testing in Python with PyArtest\u2019s Decorators](https://hychou-svm.medium.com/simplifying-regression-testing-in-python-with-pyartests-decorators-f18b33eacb04)\n- [Gist Sample Code](https://gist.github.com/HYChou0515/2fbed4f4aa9f57a9344ffbeb2326b121)\n\n\n## Advantages \n\n\n- Automation \ud83e\udd16: Artest automates the process of generating test cases for your software program while it is running, saving you time and effort in creating them manually.\n- Real-life Scenarios \ud83c\udf1f: Artest allows you to simulate real-life scenarios for regression testing, enabling you to validate your program's behavior in a more realistic context.\n- Test Case Storage \ud83d\udcc2: Artest stores the generated test cases in a designated directory, making it easy to access and manage them.\n- Regression Testing \ud83d\udc68\u200d\ud83d\udcbb: By relying on previously generated test cases, Artest enables you to perform regression testing. This means you can run the tests after making future modifications to ensure that the program continues to function correctly, catching any unexpected issues or breakdowns.\n- Stability and Dependability \ud83d\ude80: Utilizing Artest's generated test cases helps safeguard the stability and dependability of your program. By identifying and preventing issues early on, it ensures that your program remains reliable and performs as expected.\n\n## Basic use case: autoreg\n\nLet's consider a program written in Python:\n\n\n```python\ndef hello(say):\n    to = to_whom(1)\n    return f\"{say} {to}!\"\n\ndef to_whom(x):\n    choices = read_from_db()\n    # choices = [\"sir\", \"world\",]\n    return choices[x]\n\nif __name__ == \"__main__\":\n    print(hello(\"hello\"))\n    # Output: hello world!\n```\n\nIn this program, you only need to add a decorator called autoreg to the hello function:\n\n```python\nfrom artest import autoreg\n\n@autoreg(\"a5f4cb0f\")  # \ud83c\udf89 add this to auto create test case\ndef hello(say):\n    to = to_whom(1)\n    return f\"{say} {to}!\"\n\ndef to_whom(x):\n    choices = read_from_db()\n    # choices = [\"sir\", \"world\",]\n    return choices[x]\n\nif __name__ == \"__main__\":\n    print(hello(\"hello\"))\n    # Output: hello world!\n```\n\nBy applying the autoreg decorator, \nyou enable the creation of a test case associated with the \nunique function id `a5f4cb0f`\nwhenever the hello function is called.\nThe test case generation is done automatically.\nIn this updated version, we still have the to_whom function to determine the value of to.\nWhen running the program, the output remains the same: \"hello world!\".\n\n## Stubbing with autostub\nIn situations where the to_whom function takes a long time to execute or is not available during testing, you can create a stub instead. A stub is a simulated function that returns predefined values specifically defined in the test case.\n\nTo automatically create a stub, you can use the autostub decorator. When applied to a function, Artest will generate the stub for you.\n\n```python\nfrom artest import autoreg, autostub\n\n@autoreg(\"a5f4cb0f\")\ndef hello(say):\n    to = to_whom(1)\n    return f\"{say} {to}!\"\n\n@autostub(\"35988d25\")  # \ud83c\udf89 add this to auto create stub function\ndef to_whom(x):\n    choices = read_from_db()\n    # choices = [\"sir\", \"world\",]\n    return choices[x]\n\nif __name__ == \"__main__\":\n    print(hello(\"hello\"))\n    # Output: hello world!\n```\n\nIn the updated code, the to_whom function has been decorated with autostub \nusing the unique identifier \"35988d25\". \nThis allows Artest to automatically generate a stub for the to_whom function. \nInside the stub, the choices variable is typically defined in the test case \nrather than being fetched from the database, \nensuring faster and more controlled testing.\n\nWhen running the program, the output remains the same: \"hello world!\".\n\n\n## Test with artest\n\nOnce artest is installed, you can run it in test mode using the command:\n\n```bash\npython -m artest\n```\n\nThis command executes artest in test mode, \nallowing the framework to manage and execute the defined test cases \nbased on the configured environment. \nRunning artest in test mode enables the verification and \nvalidation of your program's behavior against the predefined test cases, \nensuring that the functionality operates as expected \nand remains stable even after modifications.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Automated Regression Testing Framework for Python",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/HYChou0515/py-artest",
        "Repository": "https://github.com/HYChou0515/py-artest"
    },
    "split_keywords": [
        "regression-testing",
        "automated-testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b8dbb085f510352ebba1d7a9f123168a48bda6c69ee99456ca4b8b5fc8a4062d",
                "md5": "f50370339f83d619a3897884e201f11f",
                "sha256": "39996ff4ca6082d57b0600c82755789b04a0711adbeee705ad8214c0a7c1c6f1"
            },
            "downloads": -1,
            "filename": "py_artest-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f50370339f83d619a3897884e201f11f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17989,
            "upload_time": "2023-12-05T04:59:56",
            "upload_time_iso_8601": "2023-12-05T04:59:56.272868Z",
            "url": "https://files.pythonhosted.org/packages/b8/db/b085f510352ebba1d7a9f123168a48bda6c69ee99456ca4b8b5fc8a4062d/py_artest-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c01890a4ae3e03a7ba042c4937c7f913d20c6f4bda60de01dcf66da582aa39e",
                "md5": "92d9f578eb799a5ec13a241076697f28",
                "sha256": "7c99dcbb816927e9322b84a038b785ec814f033fe740888e9c68465006a571f4"
            },
            "downloads": -1,
            "filename": "py_artest-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "92d9f578eb799a5ec13a241076697f28",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16388,
            "upload_time": "2023-12-05T04:59:58",
            "upload_time_iso_8601": "2023-12-05T04:59:58.161206Z",
            "url": "https://files.pythonhosted.org/packages/9c/01/890a4ae3e03a7ba042c4937c7f913d20c6f4bda60de01dcf66da582aa39e/py_artest-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-05 04:59:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "HYChou0515",
    "github_project": "py-artest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "py-artest"
}
        
Elapsed time: 0.31699s