Questions tagged [parametrized-testing]

91 questions
0
votes
0 answers

Is it possible in pytest_cases (pytest) to use multiple values (a list with values) in the frame of a single case?

I'm trying pytest_cases, and I came across the following, for one variable, only one value can be returned within the framework of the case. Code: from pytest_cases import case, parametrize_with_cases import pytest class CaseClass: def…
0
votes
1 answer

Pytest cannot test multiple cases with @pytest.mark.parametrize

I defined UserFactory class in tests/factories.py as shown below following the doc. *I use pytest-django and pytest-factoryboy in Django: # "tests/factories.py" import factory from django.contrib.auth.models import User class…
0
votes
0 answers

Assign Pytest markers to list of parameters

I have two markers setup in my pytest.ini file which looks like [pytest] markers = fast: mark test as fast test slow: mark test as slow test And I have a test class which uses parameters like @pytest.mark.usefixtures('page') class…
Jerry Pass
  • 105
  • 12
0
votes
1 answer

in pytest file, how to call a test for multiple fixtures?

This is a common use case which is understand doesn't have a straightforward answer. Here is my usecase: @pytest.fixture(name="hc_tags", params=[("Label", TR.LabelMixin)]) def _hc_tags(request): return request.param @pytest.fixture def…
Kabira K
  • 1,916
  • 2
  • 22
  • 38
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),…
0
votes
1 answer

How to use inherited method in parametrize in pytest?

I have the following test file import pytest def my_list_imp(): return [1, 2, 3, 4, 5] class TestParent: @pytest.mark.parametrize("item", my_list_imp()) def test_item(self, item): print("item: ", item) assert item <…
Jaxx
  • 1,355
  • 2
  • 11
  • 19
0
votes
0 answers

Is it possible skipif pytest tests depending the parameter?

I have a code which includes: test class, tests, fixtures, parameterizing Like this: import pytest @pytest.fixture def num(): return 1 @pytest.mark.parameterize('n', [1, 2]) class TestNum: def test_num(self, num, n): if n ==…
mknarespe
  • 1
  • 1
0
votes
1 answer

pytest fixture not found when used in parametrize

@pytest.fixture def text(): return "My fixture text for testing.\n" @pytest.mark.parametrize( ("some_boolean_param", "text"), [ (True, text), (False, text), ], ) def test_my_function(some_boolean_param, text,…
Nat G
  • 191
  • 1
  • 15
0
votes
0 answers

Python Unittest creates dynamic Class TestCase and Def dependent on individual TestCase

I need to run a dynamic test in Python following an input coming from a Json, the input is something like [["Element1", ["Test1", "Test2"]], ["Element2", ["Test3", "Test4 "]], ["Element3", ["Test1", "Test5", "Test6"]]] So I was expecting three…
0
votes
0 answers

Tests doesn't work properly when using @RunWith(PowerMockRunner.class) and @PowerMockRunnerDelegate(Parameterized.class)

When I run mvn test -Dtest=ClassTest it works however when I run just mvn test it fails because classes that should be mocked by PowerMock are null. Following some details: jdk 1.7 mvn 3.6.3 org.powermock
ibrz
  • 1
0
votes
0 answers

Manipulating messaging in Pa

Is there a way to use a custom format for the @Parameterized.Parameters name's in the UnitTests? My tests look like that: @RunWith(Parameterized::class) class DefaultActivityResultParserTest( private val resultCode: Int, private val…
MeLean
  • 3,092
  • 6
  • 29
  • 43
0
votes
1 answer

Adding test's docstring to the html report of a parametrized test as Description (pytest, Python)

I am running a parametrized test and I want to use kind of parametrized docstring in the html report. Normally, without the parametrization, it is the docstring of each test that I see as the description for the particular test. Now, with the…
Michala
  • 3
  • 2
0
votes
1 answer

pytest results not matching - data corrupted somehow?

I have the following python code: class CSVFile: def __init__(self, filename): self.filename = filename def write_csv_line(self, row, mode): for value in row: if value == "None": value = "" …
Burvil
  • 65
  • 1
  • 5
0
votes
3 answers

Automatically generate list for @pytest.mark.parametrize?

I am writing a test, using @pytest.mark.parametrize. The test looks like this: @pytest.mark.parametrize( "device_type,first_command,second_command", [ pytest.param( , , …
Ivajlo Iliev
  • 303
  • 1
  • 3
  • 19
0
votes
1 answer

pytest parametrize global variable as argument

I'm trying to run the same test for a series of arguments using @pytest.mark.parametrize. The test data must be computed dynamically, which I attempted as follows: data = [("1", "2")] @pytest.fixture(scope="class") def make_data(): global…
Gerry
  • 1,938
  • 3
  • 18
  • 25