Skip to main content

python-slots-mock-patch-object

Fix for `AttributeError: '<ClassName>' object attribute '<method>' is read-only` raised during `mock.patch.object()` teardown. Use when: (1) a Python test using `unittest.mock.patch.object(instance, "method")` passes the patched code but raises an AttributeError during context-exit (visible in the stack as `mock.py:1635` calling `delattr(self.target, self.attribute)`); (2) the target class declares `__slots__`; (3) the test was working before someone added `__slots__` to a base class or the target class itself; (4) a refactor introduced `__slots__` "for efficiency" and broke a previously-green test suite. Covers root cause (`__slots__` blocks `delattr` because it doesn't allocate `__dict__`, so the attribute can't be removed after the patch sets it), the diagnostic signature, the canonical fix (drop `__slots__` if the class is a mock target), and when `__slots__` IS the right call (when memory matters AND the class is never patched).

インストールへ移動

ソース情報

リポジトリ
cajias/claude-skills
ソースの最終更新活動
2026年7月20日 07:29
検出された SKILL.md の言語
英語
スター
0
フォーク
0

インストール方法

デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。

ソースファイルを確認

インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。