Does pytest parametrized test work with unittest class based tests?

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I've been trying to add parametrized @pytest.mark.parametrize tests to a class based unittest.

class SomethingTests(unittest.TestCase):     @pytest.mark.parametrize(('one', 'two'), [         (1, 2), (2, 3)])     def test_default_values(self, one, two):         assert one == (two + 1) 

But the parametrized stuff didn't kick in:

TypeError: test_default_values() takes exactly 3 arguments (1 given) 

I've switched to simple class based tests (without unittest). But I'd like to know if anyone tried it and it worked.

回答1:

According to pytest documentation:

unittest.TestCase methods cannot directly receive fixture function arguments as implementing that is likely to inflict on the ability to run general unittest.TestCase test suites.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!