Clean Pytest for Openclaw

A framework for writing maintainable Python tests using Fake-based implementations and contract testing.

marcoracer
v0.1.0
Feb 21, 2026
0
1.8k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install clean-pytest

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install clean-pytest using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Clean Pytest?

Clean Pytest provides a structured approach to writing maintainable Python tests within the Openclaw Skills ecosystem. It prioritizes the creation of Fake implementations over traditional mocking to ensure high test isolation and clarity. By utilizing this skill for Openclaw Skills, developers can implement a layered testing architecture that mirrors their application's design.

The core philosophy centers on explicit AAA (Arrange, Act, Assert) patterns and dependency injection via fixtures. This methodology is especially valuable for Python-based projects requiring high reliability and clear documentation of behavior through tests rather than monkey-patching magic.

Clean Pytest Use Cases

  • Setting up robust test suites for Python and MCP projects
  • Creating Fake implementations to replace flaky external dependencies
  • Validating MCP tool registrations through contract testing
  • Testing multi-layered architectures including Services and Repositories
  • Implementing complex parametrized test scenarios for edge-case coverage

How Clean Pytest Works

  1. Define Fake classes that implement the same interface as real external dependencies.
  2. Create reusable pytest fixtures that inject these Fakes into the testing environment.
  3. Structure test cases using the explicit AAA pattern for maximum readability.
  4. Implement contract tests to verify that components register correctly with expected signatures.
  5. Run the test suite using the pytest CLI to validate logic and measure coverage.

Clean Pytest Setup

Ensure you have python3 installed on your system. To start using these patterns with Openclaw Skills, install pytest and related plugins:

pip install pytest pytest-cov

Create a tests/conftest.py file to house your shared fixtures and tests/fakes.py for your in-memory dependency implementations.

Clean Pytest Data Schema & Taxonomy

The skill organizes testing data through a structured directory hierarchy and specific implementation files:

Component Location Description
Fakes tests/fakes.py In-memory implementations of external services.
Fixtures tests/conftest.py Global pytest fixtures and dependency injection setup.
Unit Tests tests/test_*.py Logic-specific tests following the AAA pattern.
Integration tests/test_integration_*.py Tests for hardware or cloud-connected components.

Clean Pytest Advanced Features

  • Conditional integration testing based on environment variables
  • Deep dependency injection within nested repository fixtures
  • Automated contract verification for MCP tool signatures
  • Multi-scenario validation using advanced pytest parametrization
  • Controlled failure simulation within Fakes for error-path testing

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*