Skip to content

Tag: pytest

unit testing with pytest parametrize

I have the following test code: This is not my real test this is just a minimal reproduce example. I need to parameterised only the input which is checked against the same code. For some reason this doesn’t work I always get: How can I fix it? Answer You can’t use @pytest.mark.parametrize on unitt…

Tests being run from imported class

I have a base class with some tests similar to this: And another class that reuses the testing logic within TestA but providing different data: Note that I am doing this and not simply creating another test in TestA because they each test a different class A and B (though the classes have the same interface) …

Flask testing with pytest, ENV is set to production?

I have built a flask app and i would like to create a test suite. Reading around it looks like pytest is the way to go; however, I am finding it very difficult to understand how to get going, I have looked at https://flask.palletsprojects.com/en/2.0.x/testing/ but am struggling to relate it to my app. my proj…

patch object spawned in sub-processs

I am using multiprocessing package for crating sub-processes. I need to handle exceptions from sub-process. catch, report, terminate and re-spawn sub-process. I struggle to create test for it. I would like to patch object which represent my sub-process and raise exception to see if handling is correct. But it…