Questions tagged [parametrize]
32 questions
2
votes
2 answers
How can I use the transformed data from the fixture for parameterization within the current test?
I have next code for pytest:
import pytest
@pytest.fixture
def my_fixture():
def _method(a_list):
return [num*0.5 for num in a_list]
return _method
# @pytest.mark.parametrize ??
def test_me(my_fixture):
pre_list = [0, 3, 1, 2]
…

KarimovAnton
- 25
- 3
2
votes
1 answer
How to avoid parametrization of a Pytest class when skipping it?
I have two Pytest classes: one test class is very fast and the other is slower, parametrizing itself with a function call and reusing that resource across multiple tests.
My problem is that, when running the quicker test via pytest test.py -k…

dbrackbill
- 23
- 3
2
votes
0 answers
What are the ways to use different fixtures with different scopes at the same time without conflicts that pytest offers
Problem:
I want to hide @pytest.mark.parametrize so that the tests look neat, I'm looking for other implementation
Describe:
What I have:
@pytest.mark.parametrize('testcase', ['C34744: Switch to all size'
…

Firstname Lastname
- 21
- 2
2
votes
1 answer
How can I pass list fixtures as arguments to pytest.parametrize?
I have a fixture that returns a list, and I want to create a test for each element in that list, so I was trying to pass it as an argument in pytest.parametrize, but it returns the whole list and just creates a single test.
@pytest.fixture()
def…

kimmil07
- 21
- 2
2
votes
2 answers
`pytest` and `yield`-based tests
I am trying to migrate a bunch of tests from nose to pytest and I am having trouble migrating one test that validates a whole process.
I have dumbed it down to represent my problem:
def is_equal(a, b):
assert a == b
def inner():
yield…

Adam Clark
- 183
- 1
- 2
- 8
1
vote
1 answer
pytest: combine class level parametrization with class scoped fixtures
I have tests that are identical for various values, so I want to parametrize the test class. Because the code is making network calls, I also want to use class scoped fixtures.
I tried
import pytest
@pytest.mark.parametrize('fruit', ['apple',…

Davina Armstrong
- 13
- 2
1
vote
1 answer
Using fixtures as parameters in @pytest.mark.parametrize
I'm trying to use the 'osc_inputs' fixture as a list of params in @pytest.mark.parametrize but it doesn't seem to take a fixture as an argument. Is there anyway of doing this?
Heres the code:
from time import sleep
import…

Harvey Fretwell
- 11
- 1
1
vote
1 answer
How to parameterize the source in Adf pipeline copy activity
I am new to Azure, so I have an SFTP server which has dev,qa and prod data, the user is same but the data is placed in separate folders, can anyone please tell me how to copy the files dynamically, that is I want to fetch the files from the dev…

Sanath V R
- 11
- 1
1
vote
4 answers
Parametric function in namespaces (C++)
I need to define 3 functions that have the same goal, but whose behaviours changes slightly based on 3 sets of constant values; in other words, i could simply write a function that does that in all 3 cases by taking those values as inputs. But since…

Torres98
- 31
- 3
1
vote
1 answer
How to parametrize class and function separately in pytest
I have a test class with 2 tests. How can I parametrize whole class while having one test parametrized additionally?
I need test_b executed 1 time for param0 and 2 times for param1
Module threads.py
Class TestThreads
Function test_a[param0]
…

Arsen
- 23
- 6
1
vote
1 answer
Data Driven - How can I use selective args/params as part of parameterize in Python?
I am looking to set up a data-driven approach for my python selenium project (there is none currently). Planning to have the data file as xlsx.
I use pytest in my project. Hence, I explored ddt, @data, @unpack and
pytest.mark.parametrize.
I am able…

harmonybells
- 11
- 3
1
vote
1 answer
Ruby: parametrize string without Ruby on rails framework (Jekyll plugin)
I have plugin that takes attribute from post's front matter and uses it in permalink. Problem is I need to clean up any accents and diacritics from the string before putting it in to the permalink. Ruby on rails has method called parametrize which…

Jan Černý
- 1,268
- 2
- 17
- 31
1
vote
2 answers
Pytests: getting error function uses no argument error
I have following code:
@pytest.fixture
def mock_path_functions(mocker, file_exists=True, file_size=10):
mock_obj = mock.Mock()
mock_obj.st_size = file_size
mocker.patch("os.path.exists", return_value=file_exists)
…

anish
- 1,035
- 4
- 13
- 27
0
votes
1 answer
How can I parametrize a function in pytest with a dynamic number of arguments that are based on another fixture?
I'm looking forward to do something similar to the solution described here:
Can I parameterize a pytest fixture with other fixtures?
But in my use case I want to have a dynamic number of tests based on a query in a database. In order to do the query…

nck
- 1,673
- 16
- 40
0
votes
0 answers
pytest: parameterize a test via loaded cfg file which has the name of the current test name
I would like to create a test that uses input parameters. The parameters exist in a configuration file (cfg) under my project. It is important to look for a cfg file with the same name as the current test to be run. In a function (under a fixture),…

ollie
- 1
- 1