Skip to content

repeated-unimplemented-test-contract

Share repeated typed fail-fast abstract operations between test fakes.

Why

Copied unconfigured operations add test support code and drift independently when a contract changes.

Fix

Use one explicit typed strict test base for the contract. Preserve each leaf fake's configured behavior and failure timing; verify that the complete base and wiring reduce maintained code.

Examples

Before — flagged Two test fakes repeat one unconfigured operation
tests/__init__.py
# Example test package.
tests/test_store.py
from abc import ABC, abstractmethod
class Store(ABC):
@abstractmethod
def read(self, key: str) -> str:
pass
class First(Store):
def read(self, key: str) -> str:
raise NotImplementedError
class Second(Store):
def read(self, key: str) -> str:
raise NotImplementedError
After — preferred Configured fake behavior belongs to the leaf
tests/__init__.py
# Example test package.
tests/test_store.py
from abc import ABC, abstractmethod
class Store(ABC):
@abstractmethod
def read(self, key: str) -> str:
pass
class First(Store):
def read(self, key: str) -> str:
raise NotImplementedError
class Second(Store):
def read(self, key: str) -> str:
return key