Skip to main content


PyPI version Python Versions Stars


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 is recommended although any package manager that supports pyproject.toml files can be used.

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

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

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:

If you want to say thank you or/and support active development of pytest-dpg consider adding a GitHub Star 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.

License

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

See LICENSE for more information.

Release files for pytest-dpg 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-dpg 0.1.5
File Size Uploaded
pytest_dpg-0.1.5.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-dpg 0.1.5
File Interpreter ABI Platform
pytest_dpg-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 18.9 kB

Release files / pytest_dpg-0.1.5.tar.gz

Download URL pytest_dpg-0.1.5.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b4e684621ffb90e7cfaecfcc8497e3b3690761feabde11dcee256a28f755feda
BLAKE2b-256 checksum
How to use checksums
cb96762fe8f67086bdf56fc634f6a978e9b4cb1f5a2b95a79e6d3a59b76bdb8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / pytest_dpg-0.1.5-py3-none-any.whl

Download URL pytest_dpg-0.1.5-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
868aa7eee5bc47e67627ab4807dd6ed172f6ee3d5a3505552a2f4273f55afb2e
BLAKE2b-256 checksum
How to use checksums
98a6d751b61fc12cea66c917c2698d730ba0f36262f9c1bb1a6f93b3beccee00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page