Questions tagged [parametrize]

32 questions
0
votes
1 answer

How to pass a function name in parametrize in pytest and How can i use that in testcase?

In the below script i would like to parametrize functions call RegisterClientCabinMovementDetection(x) and RegisterClientOccupantInSeatDetection(x) (made bold in script)so on... is there any way to parametrize function in pytest…
0
votes
1 answer

Using parametrize for multiple arguments in pytest

There is such a function: def underscore_concat(*args): return "_".join(filter(None, ([*args]))).upper() How to correctly pass multiple parameters using pytest.mark.parametrize? Something like this: @pytest.mark.parametrize("a, result",…
Luice712
  • 3
  • 2
0
votes
0 answers

pytest: use indirect parametrization in testfunctie itself

I feel like this is asking something super obvious, but I can't seem to figure it out. Let's take this example from the Pytest docs: @pytest.fixture def fixt(request): return request.param * 3 @pytest.mark.parametrize("fixt", ["a", "b"],…
Opifex
  • 362
  • 4
  • 15
0
votes
0 answers

gptoolbox Matlab: (No find: meshgrid, Parameterization QuadCover)

I want to use gptoolbox package in Matlab. but I can not find these (mesh grid, Parameterization QuadCover).what should I do? this page (https://github.com/alecjacobson/gptoolbox_ext) doesn't work. is there any alternative package for…
0
votes
0 answers

How to use variable from fixture as a parameter in @pytest.mark.parametrize()?

I hope that there is a simple solution for this, but I was unable to find anything. Basically, i have fixtures.py file where I have created a simple fixture that returns some variable: import pytest @pytest.fixture def fix_test(): value =…
BojanS
  • 1
0
votes
1 answer

Parametrize the usage of static variables in an abstract class

I am generating a report for a customer of our company. I have a abstract class with lots of static final int members: public abstract class Customer_ItemIDs { public static final int item_001 = 34535; public static final int item_002 =…
Josef
  • 77
  • 8
0
votes
0 answers

Override parametrize content before test execution

I would like to be able to dynamically parametrize a test function passed on the command line and override any previously set parametrize value. Example of command line execution: python -m pytest…
Ben
  • 21
  • 2
0
votes
0 answers

pytest how to pass an argument to a fixture

I know this question has been asked several times. Yet here I'm seeking help because the existing answers are not addressing this specific question: Here is what is working: I've a fixture called indexer (example use case), it simply returns an…
Abbas
  • 3,872
  • 6
  • 36
  • 63
0
votes
0 answers

Do we need to use parametrization for unit testing if we are 'setting mock objects' to different inputs but not using them in our code?

Here is the unit test I have written: @pytest.mark.parametrize('mock_finfo, mock_download_result', [ ({'ready': False}, None) …
Patrick_Chong
  • 434
  • 2
  • 12
0
votes
1 answer

pytest class scope parametrisation not working as expected

The idea is to re-create the 'connector' fixture for each 'port' parametrisation of the class. However, currently it only creates the fixture once for the whole test class and not on each param iteration. How would I make the fixtures scope only for…
0
votes
1 answer

How to pass name of method in pytest.parametrize for executing them in test?

I need to execute a specific fixture method, according to the id. I need smt like this. @pytest.fixture(autouse=True) def create_instance_of_class(): test_instance_of_class = TestClass() yield test_instance_of_class @pytest.mark.paramethize('id,…
0
votes
1 answer

how to use a pytest function to test different site using a different set of test data for each site such as staging/production

I have a set of pytest functions to test APIs, and test data is in a json file loaded by the pytest.mark.parametrize. Because the staging, production, and pre_production have different data but are similar, I want to save the test data in a…
Hans H
  • 3
  • 2
0
votes
0 answers

It is possible to add function to mock inside parametrized list?

I have two functions: function1 and function2 Is there a way to add them as a parameter in parameterized list and then mock somehow? What I want to do is to run test 'name1' with mocked function1 and test 'name2' with mocked function2 instead. Or…
herder
  • 412
  • 2
  • 5
  • 16
0
votes
1 answer

How to use the output of a fixture as input to a function as parametrize pytest

My aim is to pass a value to the fixture from test_add and the fixture in returns a list of tuples which will be required to pass it as parametrize to the test_add function. Below is the code iam trying for which not working File :…
killer
  • 1
  • 1
0
votes
1 answer

How to give dynamic values to parametrize @pytest.mark.parametrize in pytest

tests_arr = ['test1','test2'] logs_arr = ['log1','log2'] def List_of_Tests(): tests = tests_arr return tests def List_of_Logs(): logs = logs_arr return logs @pytest.mark.parametrize("test, log", …
Saili Gaitonde
  • 99
  • 1
  • 1
  • 8