Published on 16 November 2012, updated on 16 November 2012, Comments Mock is a Python mocking and testing library. It has become a de facto standard and is now included in the Python standard library. Lately I’ve had the chance to work on a fairly large code base built upon a service-oriented architecture. In order to test each service in isolation, we make extensive use of Mock to simulate servic
Join the official community for Google Workspace administrators In the Google Cloud Community, connect with Googlers and other Google Workspace admins like yourself. Participate in product discussions, check out the Community Articles, and learn tips and tricks that will make your work and life easier. Be the first to know what's happening with Google Workspace. ______________ Learn about more Goo
先日、ようやくPython 3系の真打ちとも言うべきメジャーバージョン、Python 3.3が正式リリースされました。 Python 3.3 Release -- Python Programing Language - Official Website decimal型の計算が速くなったとか、仮想環境pyvenvを自前で用意できるようになったとか、いろいろ面白い点があります。 その中で、私が気になったのが unittest.mock パッケージの追加です。 26.4 unittest.mock - Python 3.3 Documentation つい前回もユニットテスト用のMockライブラリを取り上げましたが、Pythonでも標準パッケージとして今回から導入されました。 オンライン実践テスト駆動開発写経会に参加できない私としては、これを弄って溜飲を下げるほかありません!使い方上記のリン
最近、Mockライブラリ http://www.voidspace.org.uk/python/mock/ を使ってみたのでメモ。 このライブラリは、その性質上、動的にメソッドや属性を作成するケースが多く、普通のPythonライブラリのようにイントロスペクションに頼って使い方を調べるのは難しい。本気で使うならまじめにドキュメントを読み込む必要がある。 関数の置き換え テスト中に呼び出される関数をMockで置き換える例。ここでは、関数 myapp.utils.func1() を置き換える。 from mock import Mock import myapp.utils # myapp.utils.func1 を、常に100を返す関数に置き換える myapp.utils.func1 = Mock(return_value=100) 戻り値が定数でない場合は、Mock()にside_effec
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く