How to parametrize fixtures and test functions¶ pytest enables test parametrization at several levels: pytest.fixture() allows one to parametrize fixture functions. @pytest.mark.parametrize allows one to define multiple sets of arguments and fixtures at the test function or class. pytest_generate_tests allows one to define custom parametrization schemes or extensions. @pytest.mark.parametrize: par
Python その2 Advent Calendar 2015の11日目の記事です。 はじめに 本記事では、pytestを使用した際に得たTipsを逆引き形式でまとめている。 また以下のリポジトリに本記事の内容を含んだサンプルプロジェクト(Python3.5.0/pytest2.8.4で確認)を置いているため、合わせて参考にして頂ければ。 https://github.com/FGtatsuro/pytest_sample pytestの特徴 pytestはその名のとおり、Pythonで書かれたテストライブラリ。同様のライブラリとしては、unittestやnoseがある。 上記2つのツールに精通していないため、それらと比較した形での評価は下せないが、個人的には以下のような点が特徴的だと感じた。 独自のassertメソッド(ex. assertEquals)を定義せずに、Python標準のa
1. 5-minute intro to property-based testing in Python with hypothesis Franklin Chen http://FranklinChen.com/ http://ConscientiousProgrammer.com/ Pittsburgh Python Meetup June 26, 2013 2. Property-based testing vs. example-based testing Example-based testing: assert that a property is true for some values. Are list appends associative? Write some examples def test_list_append_associative_example1()
Contents Home Get started How-to guides Reference guides Explanation Complete table of contents Library of examples About the project Changelog Contributing Backwards Compatibility Sponsor pytest for Enterprise License Contact Channels Full pytest documentation Start here How-to guides Reference guides Explanation Further topics Related Topics Documentation overview Next: Get Started Useful Links
pytest *1 に関連して tox も一緒に覚えておくと良さそうです。 @t2y @methane 少し前からtox + py.test が鉄板な気がしますねえ 2012-02-07 20:50:23 via twicca to @t2y tox については id:Ehren の入門記事が分かりやすいです。 Pythonでのテストツールtox入門 - Keep on moving 複数の Python バージョン毎に virtualenv で仮想環境を作成して、そこに自分のパッケージと必要なライブラリ等をインストールして、それぞれのバージョン毎にテストをまとめて実行してくれます。例えば、Python 2/3 の両対応を考えたときに、自分で環境を切り分ける手間隙を軽減できて、かなり便利です。ここで言う Python 2/3 両対応は 2.6/2.7 と 3.x の対応を指します *2 。
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く