From python-testing
Behavior-driven testing philosophy: diamond approach, fakes over mocks, dependency injection
How this skill is triggered — by the user, by Claude, or both
Slash command
/python-testing:testing-philosophyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```python
# Good
def test_order_creation_reserves_inventory():
fake_repo = InMemoryOrderRepository()
fake_inventory = InMemoryInventoryService()
create_order(customer_id="c1", product_id="p1", repo=fake_repo, inventory=fake_inventory)
assert fake_inventory.reserved["p1"] == 1
# Bad
def test_order_sets_status_field():
order = Order()
order._set_status("pending")
assert order._status == "pending"
# Good
def test_premium_users_get_discount():
customer = CustomerFactory(tier=Tier.PREMIUM)
product = ProductFactory(price=Decimal("100"))
order = create_order(customer.id, product.id)
assert order.total == Decimal("80")
# Bad
def test_premium_users_get_discount():
customer = CustomerFactory(tier=Tier.PREMIUM)
order = create_order(customer.id, ProductFactory(price=Decimal("100")).id)
assert order.total == Decimal("80")
assert order.discount_applied is True
another_order = create_order(customer.id, ProductFactory().id)
# Good
def test_user_cannot_order_out_of_stock_product():
...
def test_order_total_includes_shipping_for_non_premium_users():
...
# Bad
def test_order_validation():
...
def test_calculate_total_method():
...
# Good
class InMemoryOrderRepository:
def __init__(self):
self._orders: dict[str, Order] = {}
def save(self, order: Order) -> None:
self._orders[order.id] = order
def get(self, order_id: str) -> Order | None:
return self._orders.get(order_id)
# Bad
def test_order_saved(mocker):
mock_repo = mocker.Mock()
create_order("c1", "p1", repo=mock_repo)
mock_repo.save.assert_called_once() # Breaks if save() renamed
# Good
def create_order(customer_id: str, product_id: str, repo: OrderRepository) -> Order:
order = Order(customer_id, product_id)
repo.save(order)
return order
# Bad
def create_order(customer_id: str, product_id: str) -> Order:
repo = PostgreSQLOrderRepository()
order = Order(customer_id, product_id)
repo.save(order)
return order
npx claudepluginhub remihuguet/rems-buddy --plugin python-testingProvides framework-agnostic testing principles covering test philosophy, structure, and mocking boundaries. Use when writing, reviewing, or debugging tests.
Writes behavior-focused tests using Testing Trophy model: integration first with real dependencies, minimal mocking. For writing tests, choosing types, or avoiding anti-patterns.
Guides effective test writing with AAA structure, testing pyramid, mock boundaries. Debugs flaky/brittle tests, chooses unit/integration/E2E boundaries.