Skip to main content

Pytest prompt fixtures for the Klab Pytest Toolkit

Project description

Klab Pytest Toolkit - Prompt

Custom pytest fixtures for interactive user prompts during test execution using tkinter UI dialogs. The goal is to allow testers to interact with the test process, providing confirmations or displaying important information.

At the moment the package provides the following fixtures:

  • ui_prompt_factory: Factory for creating multiple prompt instance. With the factory you can create the prompt fixture.

Installation

pip install klab-pytest-toolkit-prompt

Usage

UI Prompt

Create the fixture

The factory class PromptFactory can be used to create multiple prompt instances. This is already provided as a pytest fixture prompt_factory.

@pytest.fixture
def ui_prompt(prompt_factory) -> PromptInterface:
    """Fixture to provide a UI prompt interface for user interaction during tests."""
    return prompt_factory.create_prompt(prompt_type=PromptFactory.PromptType.UI_PROMPT)

Functions

The following functions are available on the PromptInterface instance:

Show Information Dialog

def test_with_info(ui_prompt):
    """Display information to the user."""
    ui_prompt.show_info("Test is about to perform a critical operation")
    
    # Continue with test
    perform_operation()

Get User Confirmation

def test_with_confirmation(ui_prompt):
    """Get user confirmation before proceeding."""
    if ui_prompt.confirm_action("Continue with destructive test?"):
        # User clicked Yes
        perform_destructive_operation()
    else:
        # User clicked No
        pytest.skip("User cancelled the test")

With Timeout (Auto-close)

def test_with_timeout(ui_prompt):
    """Show dialog that auto-closes after timeout."""
    # Dialog closes automatically after 5 seconds
    ui_prompt.show_info("This will auto-close in 5 seconds", timeout=5)
    
    # Confirmation dialog with timeout (returns False if timeout expires)
    result = ui_prompt.confirm_action(
        "Click within 10 seconds",
        timeout=10
    )

Examples

See the tests directory for example test cases demonstrating the usage of the prompt fixtures.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

klab_pytest_toolkit_prompt-0.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

klab_pytest_toolkit_prompt-0.0.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

klab_pytest_toolkit_prompt-0.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file klab_pytest_toolkit_prompt-0.0.0.tar.gz.

File metadata

  • Download URL: klab_pytest_toolkit_prompt-0.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for klab_pytest_toolkit_prompt-0.0.0.tar.gz
Algorithm Hash digest
SHA256 2033b895408c3823324e49157210a5a2e23137714fb6308738ed39828e93eb99
MD5 3a0d8306bbdc035d9c1e28a99be4b05d
BLAKE2b-256 4a88d3c812050c1b8fd0a0acf8216a34bf79239cc5f8c9690a231b5338f97c42

See more details on using hashes here.

File details

Details for the file klab_pytest_toolkit_prompt-0.0.0.0-py3-none-any.whl.

File metadata

  • Download URL: klab_pytest_toolkit_prompt-0.0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for klab_pytest_toolkit_prompt-0.0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f20afb5ed36528d6405ef4f51aff1925933c5bc103bc74bba41214682a9fdeb4
MD5 8ed230c20526c4bf80eecc1acf20b0ad
BLAKE2b-256 bc6932ef5e381887d83a31678117a5fc78090981021624603cfb79441dff200d

See more details on using hashes here.

File details

Details for the file klab_pytest_toolkit_prompt-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: klab_pytest_toolkit_prompt-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for klab_pytest_toolkit_prompt-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18042ff946086adc64d082bb6e75de3eb45ad4c6576c0ac683e3dea8b06480fa
MD5 c1df9ddba9beb6a2915e8869dc820cda
BLAKE2b-256 d93867b6904bf2e8141632b5679f787b1f51f5f33353e8fc7c5c5f661c4ec68c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page