textual-testing
Tests Textual TUI applications using the built-in testing framework. Covers headless mode testing with App.run_test(), complete Pilot API (mouse, keyboard, timing, animations), widget querying, and worker management. Use when: writing tests for TUI widgets, testing user interactions (clicks, keypresses, hover), verifying widget state, testing event handling, or running integration tests. Primary skill for functional Textual testing.
What this skill does
# Textual Testing
Functional testing for Textual applications using `App.run_test()` and the `Pilot` class.
## Quick Start
```python
async def test_my_app():
"""Test a Textual application."""
app = MyApp()
async with app.run_test() as pilot:
# Interact with app
await pilot.press("enter")
await pilot.pause()
# Assert on state
widget = pilot.app.query_one("#status")
assert widget.renderable == "Done"
```
## pytest Configuration
```toml
# pyproject.toml
[tool.pytest.ini_options]
asyncio_mode = "auto" # No @pytest.mark.asyncio needed
testpaths = ["tests"]
```
## App.run_test() Method
Run app in headless mode (no terminal output, all other behavior identical):
```python
async with app.run_test(size=(80, 24)) as pilot:
# size: terminal dimensions (width, height), default (80, 24)
...
```
## Complete Pilot API
### Properties
```python
pilot.app # Access the App instance being tested
```
### Mouse Operations
```python
# Click widget by selector, type, or instance
await pilot.click("#button") # CSS selector
await pilot.click(Button) # Widget type
await pilot.click(my_widget) # Widget instance
await pilot.click(offset=(40, 12)) # Absolute coordinates
# Click with modifiers
await pilot.click("#item", shift=True)
await pilot.click("#item", control=True)
await pilot.click("#item", meta=True)
# Multiple clicks
await pilot.click("#item", times=2) # Double-click
await pilot.click("#item", times=3) # Triple-click
await pilot.double_click("#item") # Alias
await pilot.triple_click("#item") # Alias
# Click with offset from selector
await pilot.click("#widget", offset=(10, 5))
# Hover (for testing hover states, tooltips)
await pilot.hover("#menu-item")
# Raw mouse events (for drag-and-drop)
await pilot.mouse_down("#draggable")
await pilot.hover("#drop-target")
await pilot.mouse_up("#drop-target")
```
### Keyboard Operations
```python
# Press single key
await pilot.press("enter")
# Press multiple keys in sequence
await pilot.press("h", "e", "l", "l", "o")
# Type string (unpack into characters)
await pilot.press(*"hello world")
# Special keys
await pilot.press("tab", "enter", "escape", "backspace", "delete")
await pilot.press("up", "down", "left", "right")
await pilot.press("home", "end", "pageup", "pagedown")
await pilot.press("f1", "f2", "f12")
# Modifier combinations
await pilot.press("ctrl+c", "ctrl+s", "ctrl+shift+p")
await pilot.press("shift+tab", "alt+f4", "meta+s")
```
### Timing Control
```python
# Wait for message queue to drain
await pilot.pause()
# Wait for messages + additional delay
await pilot.pause(0.5) # 0.5 seconds extra
```
### Animation Handling
```python
# Wait for current animations to complete
await pilot.wait_for_animation()
# Wait for all current AND scheduled animations
await pilot.wait_for_scheduled_animations()
```
### App Control
```python
# Exit app with return value
await pilot.exit(result={"status": "success"})
# Resize terminal during test
await pilot.resize_terminal(120, 40)
await pilot.pause() # Let resize events propagate
```
### Worker Management
```python
# Wait for all background workers to complete
await pilot.app.workers.wait_for_complete()
```
## Widget Querying
```python
# Query single widget (raises if not found or multiple matches)
button = pilot.app.query_one("#submit")
button = pilot.app.query_one(Button)
button = pilot.app.query_one("#submit", Button) # With type validation
# Query multiple widgets
buttons = pilot.app.query(Button)
buttons = pilot.app.query(".action-button")
# Query methods
first = pilot.app.query(Button).first()
last = pilot.app.query(Button).last()
# Iterate
for button in pilot.app.query(".action-button"):
assert not button.disabled
```
## Common Test Patterns
### Test Button Click
```python
async def test_button_click():
class MyApp(App):
clicked = False
def compose(self):
yield Button("Click", id="btn")
def on_button_pressed(self):
self.clicked = True
async with MyApp().run_test() as pilot:
await pilot.click("#btn")
await pilot.pause()
assert pilot.app.clicked is True
```
### Test Text Input
```python
async def test_text_input():
class MyApp(App):
def compose(self):
yield Input(id="input")
async with MyApp().run_test() as pilot:
await pilot.click("#input")
await pilot.press(*"hello world")
await pilot.pause()
input_widget = pilot.app.query_one("#input", Input)
assert input_widget.value == "hello world"
```
### Test Keyboard Binding
```python
async def test_keyboard_binding():
class MyApp(App):
BINDINGS = [("ctrl+s", "save", "Save")]
saved = False
def action_save(self):
self.saved = True
async with MyApp().run_test() as pilot:
await pilot.press("ctrl+s")
await pilot.pause()
assert pilot.app.saved is True
```
### Test Background Worker
```python
async def test_background_worker():
class MyApp(App):
data = None
@work
async def fetch_data(self):
await asyncio.sleep(0.1)
self.data = {"loaded": True}
async with MyApp().run_test() as pilot:
pilot.app.fetch_data()
await pilot.app.workers.wait_for_complete()
assert pilot.app.data == {"loaded": True}
```
### Test Different Terminal Sizes
```python
async def test_responsive_layout():
app = MyApp()
# Test small terminal
async with app.run_test(size=(40, 20)) as pilot:
sidebar = pilot.app.query_one("#sidebar")
assert not sidebar.is_visible # Hidden on small screens
# Test large terminal
async with app.run_test(size=(120, 40)) as pilot:
sidebar = pilot.app.query_one("#sidebar")
assert sidebar.is_visible # Visible on large screens
```
### Test with Terminal Resize
```python
async def test_resize_handling():
async with MyApp().run_test(size=(80, 24)) as pilot:
assert pilot.app.size == (80, 24)
await pilot.resize_terminal(120, 40)
await pilot.pause()
assert pilot.app.size == (120, 40)
```
## Common Pitfalls
| Pitfall | Solution |
|---------|----------|
| Assertion fails before update | Add `await pilot.pause()` after interactions |
| Worker result not available | Use `await pilot.app.workers.wait_for_complete()` |
| Animation state varies | Use `await pilot.wait_for_animation()` |
| Missing `async def` | All test functions must be `async def` |
| Missing `await` | All pilot methods are async and need `await` |
## See Also
- [textual-snapshot-testing](../textual-snapshot-testing) - Visual regression testing
- [textual-test-fixtures](../textual-test-fixtures) - Pytest fixture patterns
- [textual-test-patterns](../textual-test-patterns) - Testing recipes by scenario
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.