Python のテストフレームワーク nose を使ってテストを書く時に, setup と teardown がいつ実行されるかがよくわからなかったので,まとめました. まとめ 各テストケースの前後に setup/treadown を行いたい場合 -> クラスを使う テストを行う前後1回だけ setup/teardown を行いたい場合 -> モジュールを使う 各テストケースの前後に setup/treadown を行いたい場合 クラスを使ってテストを書きます。 #! /usr/bin/env python #-*- encoding: utf-8 -*- import nose class TestMyUtillClass: def out(self, message): debug_file = open('debug4class.txt', 'a') debug_file.write