Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created May 28, 2014 10:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podhmo/1bf1d58f30e66639ff44 to your computer and use it in GitHub Desktop.
Save podhmo/1bf1d58f30e66639ff44 to your computer and use it in GitHub Desktop.
# -*- coding:utf-8 -*-
import pytest
xs = ((1, 1, 1),
(3, 4, 12),
pytest.mark.xfail((4, 4, 8)))
@pytest.mark.parametrize("x, y, expected", xs)
def test_mul(x, y, expected):
assert x * y == expected
# py.test <filename>
@podhmo
Copy link
Author

podhmo commented May 28, 2014

$ py.test
============================= test session starts ==============================
platform darwin -- Python 3.3.1 -- py-1.4.20 -- pytest-2.5.2
collected 3 items

test_paramaterize_howto.py ..x

===================== 2 passed, 1 xfailed in 0.03 seconds ======================

@podhmo
Copy link
Author

podhmo commented May 28, 2014

pytestのparameterized testの仕方結構癖がある。pytest.mark.parametrizeに渡す文字列はwrapした関数の引数と同じ形式にする必要があった。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment