タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

pytestに関するyubessyのブックマーク (2)

  • pytestでテストケースの前後処理をする - Qiita

    セットアップコードのモジュールはconftest.pyという名前にしないとpytestが拾ってくれません。 テストケースのモジュールはtest_*.pyのような名前にしないと、同じくpytestが拾ってくれません。 モジュールに限らず、testと接頭辞をつける系の小ネタはpythonテスト界隈の全般的なお作法なようですね(Javaのspock時は割とフリーダムな名前をつけていたことを思い出しながら)。 さて、以上踏まえて、個別のモジュールを見ていきたいと思います。 コーディング はい、ドーン!といきたいところですが、実はやり方は2つあるようです。 yield命令を使う addfinalizer命令を使う ですが、今回はとてもシンプルなyield命令を使うことにします。 先ほどの目的順に見ていきましょう。 前後処理などセットアップコードを共通化したい では、ドーン! import pytes

    pytestでテストケースの前後処理をする - Qiita
  • About fixtures - pytest documentation

    pytest fixtures are designed to be explicit, modular and scalable. What fixtures are¶ In testing, a fixture provides a defined, reliable and consistent context for the tests. This could include environment (for example a database configured with known parameters) or content (such as a dataset). Fixtures define the steps and data that constitute the arrange phase of a test (see Anatomy of a test).

  • 1