Skip to content

Tag: pytest

Provide default argument value for py.test fixture function

Is there a better way for me to provide default value for argument pytest.fixture function? I have a couple of testcases that requires to run fixture_func before testcase and I would like to use default value for argument in fixture if none of them is provided. The only code I can come up with is as follows. …

py.test assert may raise, and if it raises it will be __

Is there pytest functionality similar to pytest.raises that passes iff the block raises the specified exception, or doesn’t raise at all? Something like: This question came up in the following situation.. The function to test: A couple of simple tests (fixtures below): The fixtures: the indicated <==…

pytest.mark.parameterize not “finding” fixtures

I’m writing tests for a small library and I decided to use py.test after hearing so many good things about it. However, pytest.mark.parameterize is giving me some issues. At first, I thought maybe I just mismatched some parens and it went off looking for a fixture elsewhere. So I decided to start with t…

What’s the idea behind pytest-cache?

pytest-cache It seems to be a tool to cache func/args->result pairs and even persist them between testsuite-runs. Which seems like a great idea to speed things up. However I haven’t noticed any mention of automatically detecting a change of a function source code and invalidating corresponding cache …

PyCharm noinspection for whole file?

Is it possible to disable an inspection for the whole file in PyCharm? The reason this is needed is when dealing with py.test. It uses fixtures which appear to shadow function parameters, and at the same time cause unresolved references. e.g.: There is also other warnings from py.test, such as using pytest.ra…

how to execute multiple tests on multiple items with py.test

I’m a novice in python and also in py.test. I’m searching a way to run multiple tests on multiple items and cannot find it. I’m sure it’s quite simple when you know how to do it. I have simplified what I’m trying to do to make it simple to understand. If I have a Test class who d…