pytest-dpg


Namepytest-dpg JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
Summarypytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications
upload_time2024-08-13 17:03:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords dearpygui dpg
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
    <!-- Please provide path to your logo here -->
    <!-- <img src="" alt="Logo" width="200" height="200"> -->
  </a>
</h1>

<div align="center">
  pytest-dpg
  <br />
  <a href="https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=bug&template=01_BUG_REPORT.md&title=bug%3A+">Report a Bug</a>
  ·
  <a href="https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=enhancement&template=02_FEATURE_REQUEST.md&title=feature%3A+">Request a Feature</a>
  ·
  <a href="https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+">Ask a Question</a>
</div>

<div align="center">
<br/>


[![PyPI version](https://img.shields.io/pypi/v/pytest-dpg?color=mediumseagreen)](https://pypi.org/project/pytest-dpg/)
[![Python Versions](https://img.shields.io/pypi/pyversions/pytest-dpg?color=mediumseagreen)](https://pypi.org/project/pytest-dpg/)
[![Stars](https://img.shields.io/github/stars/tbruno25/pytest-dpg?color=mediumseagreen)](https://github.com/Tbruno25/pytest-dpg/stargazers)
</div>

---


# About

`pytest-dpg` is a pytest plugin for testing DearPyGui (DPG) applications. 

## Features

- Automates user interactions like clicking buttons, switching tabs, and dragging sliders
- Runs GUI tests in a separate process for concurrency, stability, and isolation
- Easy to use API for interacting with DPG elements
- Requires no application code modifications

## Installation


[pipx](https://pypa.github.io/pipx/) is recommended although any package manager that supports `pyproject.toml` files can be used.

```bash
pipx install pytest-dpg
``` 

## How it works

pytest-dpg creates a controlled environment for testing before performing introspection on the application:

- **DPG Loop Patching**: `dpgtester` patches DearPyGui's main loop (`dpg.start_dearpygui()`) with a custom loop that allows for command insertion between frames.
- **Item Identification**: utilizes DPG's internal APIs to locate items based on their labels, values, or adjacent items. This allows it to (hopefully) find the correct screen coordinates for interactions.

## Usage
pytest-dpg automatically makes the pytest fixture `dpgtester` available for use

```python
def test_my_gui(dpgtester):
    # This function should setup and start your application when run
    func = your_gui_function

    # Start your GUI application
    dpgtester.set_target(func)
    dpgtester.start_gui()

    # Interact with GUI elements
    dpgtester.click_button("Submit")
    dpgtester.click_tab("Settings")
    dpgtester.drag_slider("Volume", 75)

```

## Limitations
While pytest-dpg aims to provide a robust testing solution for DearPyGui applications, there are some current limitations to be aware of:

- **Limited Application Support:**
only applications that utilize `dpg.start_dearpygui()` are curently supported
- **Limited Widget Support:** ***only*** the following widgets are currently supported
    - regular button
    - horizontal slider
    - tab
    - collapsible header
    - text input box
    - combo box

- **Complex Layouts:** Very complex or dynamically changing layouts might pose challenges for element identification and interaction.

We are continuously working on improving pytest-dpg and addressing these limitations. Contributions and feedback are always welcome!

## API Reference

### dpgtester

- `set_target(func: Callable)` Set the target function for the GUI test
- `start_gui()` Start the GUI in a separate process
- `python stop_gui()` Stop the GUI process if it's running
- `click_button(label: str)` Click a button with the given label
- `click_tab(label: str)` Click a tab with the given label
- `drag_slider(label: str, value: int)` Drag a slider to the specified value

### pytest_dpg
By default, dpgtester will execute actions as quickly as possible.
To slow down interactions, the following attributes can be increased
```python
import pytest_dpg

pytest_dpg.PAUSE = 0.25
pytest_dpg.MINIMUM_DURATION = 0.5
```

## Support

Reach out to the maintainer at one of the following places:
- [GitHub issues](https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+)
- Contact options listed on [this GitHub profile](https://github.com/tbruno25)

If you want to say **thank you** or/and support active development of pytest-dpg consider adding a [GitHub Star](https://github.com/tbruno25/pytest-dpg) to the project.


## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

- Fork the repository
- Create your feature branch (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a Pull Request

For a full list of all authors and contributors, see [the contributors page](https://github.com/tbruno25/pytest-dpg/contributors).

## License

This project is licensed under the **GNU General Public License v3**.

See [LICENSE](LICENSE) for more information.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytest-dpg",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "dearpygui, dpg",
    "author": null,
    "author_email": "TJ <tbruno25@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/cb/96/762fe8f67086bdf56fc634f6a978e9b4cb1f5a2b95a79e6d3a59b76bdb8f/pytest_dpg-0.1.5.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n    <!-- Please provide path to your logo here -->\n    <!-- <img src=\"\" alt=\"Logo\" width=\"200\" height=\"200\"> -->\n  </a>\n</h1>\n\n<div align=\"center\">\n  pytest-dpg\n  <br />\n  <a href=\"https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=bug&template=01_BUG_REPORT.md&title=bug%3A+\">Report a Bug</a>\n  \u00b7\n  <a href=\"https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=enhancement&template=02_FEATURE_REQUEST.md&title=feature%3A+\">Request a Feature</a>\n  \u00b7\n  <a href=\"https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+\">Ask a Question</a>\n</div>\n\n<div align=\"center\">\n<br/>\n\n\n[![PyPI version](https://img.shields.io/pypi/v/pytest-dpg?color=mediumseagreen)](https://pypi.org/project/pytest-dpg/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/pytest-dpg?color=mediumseagreen)](https://pypi.org/project/pytest-dpg/)\n[![Stars](https://img.shields.io/github/stars/tbruno25/pytest-dpg?color=mediumseagreen)](https://github.com/Tbruno25/pytest-dpg/stargazers)\n</div>\n\n---\n\n\n# About\n\n`pytest-dpg` is a pytest plugin for testing DearPyGui (DPG) applications. \n\n## Features\n\n- Automates user interactions like clicking buttons, switching tabs, and dragging sliders\n- Runs GUI tests in a separate process for concurrency, stability, and isolation\n- Easy to use API for interacting with DPG elements\n- Requires no application code modifications\n\n## Installation\n\n\n[pipx](https://pypa.github.io/pipx/) is recommended although any package manager that supports `pyproject.toml` files can be used.\n\n```bash\npipx install pytest-dpg\n``` \n\n## How it works\n\npytest-dpg creates a controlled environment for testing before performing introspection on the application:\n\n- **DPG Loop Patching**: `dpgtester` patches DearPyGui's main loop (`dpg.start_dearpygui()`) with a custom loop that allows for command insertion between frames.\n- **Item Identification**: utilizes DPG's internal APIs to locate items based on their labels, values, or adjacent items. This allows it to (hopefully) find the correct screen coordinates for interactions.\n\n## Usage\npytest-dpg automatically makes the pytest fixture `dpgtester` available for use\n\n```python\ndef test_my_gui(dpgtester):\n    # This function should setup and start your application when run\n    func = your_gui_function\n\n    # Start your GUI application\n    dpgtester.set_target(func)\n    dpgtester.start_gui()\n\n    # Interact with GUI elements\n    dpgtester.click_button(\"Submit\")\n    dpgtester.click_tab(\"Settings\")\n    dpgtester.drag_slider(\"Volume\", 75)\n\n```\n\n## Limitations\nWhile pytest-dpg aims to provide a robust testing solution for DearPyGui applications, there are some current limitations to be aware of:\n\n- **Limited Application Support:**\nonly applications that utilize `dpg.start_dearpygui()` are curently supported\n- **Limited Widget Support:** ***only*** the following widgets are currently supported\n    - regular button\n    - horizontal slider\n    - tab\n    - collapsible header\n    - text input box\n    - combo box\n\n- **Complex Layouts:** Very complex or dynamically changing layouts might pose challenges for element identification and interaction.\n\nWe are continuously working on improving pytest-dpg and addressing these limitations. Contributions and feedback are always welcome!\n\n## API Reference\n\n### dpgtester\n\n- `set_target(func: Callable)` Set the target function for the GUI test\n- `start_gui()` Start the GUI in a separate process\n- `python stop_gui()` Stop the GUI process if it's running\n- `click_button(label: str)` Click a button with the given label\n- `click_tab(label: str)` Click a tab with the given label\n- `drag_slider(label: str, value: int)` Drag a slider to the specified value\n\n### pytest_dpg\nBy default, dpgtester will execute actions as quickly as possible.\nTo slow down interactions, the following attributes can be increased\n```python\nimport pytest_dpg\n\npytest_dpg.PAUSE = 0.25\npytest_dpg.MINIMUM_DURATION = 0.5\n```\n\n## Support\n\nReach out to the maintainer at one of the following places:\n- [GitHub issues](https://github.com/tbruno25/pytest-dpg/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+)\n- Contact options listed on [this GitHub profile](https://github.com/tbruno25)\n\nIf you want to say **thank you** or/and support active development of pytest-dpg consider adding a [GitHub Star](https://github.com/tbruno25/pytest-dpg) to the project.\n\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n- Fork the repository\n- Create your feature branch (git checkout -b feature/AmazingFeature)\n- Commit your changes (git commit -m 'Add some AmazingFeature')\n- Push to the branch (git push origin feature/AmazingFeature)\n- Open a Pull Request\n\nFor a full list of all authors and contributors, see [the contributors page](https://github.com/tbruno25/pytest-dpg/contributors).\n\n## License\n\nThis project is licensed under the **GNU General Public License v3**.\n\nSee [LICENSE](LICENSE) for more information.",
    "bugtrack_url": null,
    "license": null,
    "summary": "pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications",
    "version": "0.1.5",
    "project_urls": {
        "repository": "https://github.com/tbruno25/pytest-dpg"
    },
    "split_keywords": [
        "dearpygui",
        " dpg"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98a6d751b61fc12cea66c917c2698d730ba0f36262f9c1bb1a6f93b3beccee00",
                "md5": "230ff0c39d046e412ce4871797c67b5d",
                "sha256": "868aa7eee5bc47e67627ab4807dd6ed172f6ee3d5a3505552a2f4273f55afb2e"
            },
            "downloads": -1,
            "filename": "pytest_dpg-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "230ff0c39d046e412ce4871797c67b5d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9737,
            "upload_time": "2024-08-13T17:03:25",
            "upload_time_iso_8601": "2024-08-13T17:03:25.640291Z",
            "url": "https://files.pythonhosted.org/packages/98/a6/d751b61fc12cea66c917c2698d730ba0f36262f9c1bb1a6f93b3beccee00/pytest_dpg-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb96762fe8f67086bdf56fc634f6a978e9b4cb1f5a2b95a79e6d3a59b76bdb8f",
                "md5": "86c5374c68ed6a86a8552268945d7793",
                "sha256": "b4e684621ffb90e7cfaecfcc8497e3b3690761feabde11dcee256a28f755feda"
            },
            "downloads": -1,
            "filename": "pytest_dpg-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "86c5374c68ed6a86a8552268945d7793",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 9141,
            "upload_time": "2024-08-13T17:03:27",
            "upload_time_iso_8601": "2024-08-13T17:03:27.183310Z",
            "url": "https://files.pythonhosted.org/packages/cb/96/762fe8f67086bdf56fc634f6a978e9b4cb1f5a2b95a79e6d3a59b76bdb8f/pytest_dpg-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-13 17:03:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tbruno25",
    "github_project": "pytest-dpg",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pytest-dpg"
}
        
Elapsed time: 0.72689s