タグ

PythonとTDDに関するt_a_oのブックマーク (3)

  • TDDjangoTutorial

    Seriously. This tutorial badly needs updating. Everything is in the book, and much, much more. It's also written in step-by-step tutorial form, it uses the latest django, and it really is free. No catch. What's the approach? Test-First! So, before we're allowed to write any real production code, we write some tests. We start by writing some browser tests - what I call functional tests, which simul

  • mockはこう使え - atsuoishimoto's diary

    最近、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

    mockはこう使え - atsuoishimoto's diary
  • pyhack5 DocTestで覚えるTDDのリズム

    Python Hack-a-thon 5 ハンズオン 中級コース¶ DocTestで覚えるTDDのリズム¶ 担当: 清水川 このハンズオンでは、以下の内容について体験していきます。 PythonのDocTestを使ってみよう TDDをDocTestでやってみよう 環境¶ WindowsでもMacでもUnix系でも。 Pytohn2.6~3.x ただしこの資料は2.6しか動作保証しません Test Driven Development について¶ Test Driven Development = TDD, 日語で言うと テスト駆動開発 です。 TDDはその名の通り、テストで開発を駆動する手法で、簡単に言うと以下の ステップで実装を進めていきます。 テストコードを書く テストを実行する(実装前なのでエラーになる = RED) テストコードを通す実装をする(fake it) テストを実行する

    t_a_o
    t_a_o 2010/12/04
  • 1