Questions tagged [parametrized-testing]

91 questions
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',…
1
vote
0 answers

Can I rely on a pytest test parametrization to be passed on to a fixture?

Here's a minimal example of a behaviour that I "discovered": import pytest @pytest.fixture(scope="function") def introduce_yourself(my_name): return f"Hello, my name is {my_name}" @pytest.mark.parametrize("my_name", ["Alice", "Bob"]) def…
bolla
  • 359
  • 1
  • 3
  • 10
1
vote
1 answer

How can I dynamically generate pytest parametrized fixtures from imported helper methods?

What I want to achieve is basically this but with a class scoped, parametrized fixture. The problem is that if I import the methods (generate_fixture and inject_fixture) from a helper file the inject fixture code seems to be getting called too late.…
GrayedFox
  • 2,350
  • 26
  • 44
1
vote
1 answer

How to parametrize a fixture with multiple parameters

I have a fixture which in I want to use request.param multiple times. @pytest.fixture def get_settings(request): with mock.patch("helpers.helpers.get_settings") as mocked_settings: mocked_settings.return_value = Settings( …
Ghasem
  • 14,455
  • 21
  • 138
  • 171
1
vote
0 answers

Boost test fixture parameter

I want to write a parametrised unit test using boost::test. Preferably I'd like to pass parameters to my fixture class. I write multiple test cases with the same setup and tear-down scenarios, so it'd be pretty handy. Unfortunately, I'm aware that…
Patryk
  • 136
  • 8
1
vote
0 answers

pytest - got empty parameter set

I am trying to automate an api, basically what I want to do is execute test_001_post_desafio, save information from its response in a list and use it in test_002_post_validate, but when executing the latter with pytest I get the error: "SKIPPED [1]…
Fedex
  • 11
  • 2
1
vote
1 answer

Function in pytest file works only with hard coded values

I have the below test_dss.py file which is used for pytest: import dataikuapi import pytest def setup_list(): client = dataikuapi.DSSClient("{DSS_URL}", "{APY_KEY}") client._session.verify = False project =…
1
vote
1 answer

Renaming parameters in pytest.mark.parametrize

I have a code which uses files in a directory as parameters: def get_testcases(directory): files = list(os.listdir(directory)) testcases = filter(lambda x: x.endswith('.yaml'), files) for testcase in testcases: postconf =…
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
1
vote
1 answer

How to call objects' attributes in Pytest parametrize feature

I have some fixtures that just return the objects of a class. The objects contain a property of that class which I am trying to verify in pytest, so the code looks something like this: from main import My_class import pytest @pytest.fixture() def…
Massina_CF
  • 13
  • 3
1
vote
2 answers

How to use JUnit5 Parametrized Test CSV file source?

I am trying to run a parametrized test from CSV-file. It is working if I use just CSVSource like that: @ParameterizedTest @CsvSource({ "a,A", "b,B" }) void csvSourceTest(String input, String expected) { String actualValue = input.toUpperCase(); …
user8444746
1
vote
1 answer

Is there a possibility to write parametrized tests with Ruby+Minitest?

I've recently started working on a automated testing project, that uses Ruby+Minitest and I wonder if I can run 1 test as many times as many input data I provide. So, I have smth like (code is under NDA so I can't provide real examples) def…
Wolffather
  • 13
  • 2
1
vote
1 answer

Pytest parametrize test using function

I'm trying to parametrize pytest test with a function that yields values of parameters. I want it to run test separately for each value. Here is example code: def provider(): yield pytest.param([1, 2]) class Test: …
Diana
  • 86
  • 6
1
vote
1 answer

How to parameterized setUp method with nose_parameterized

I'm using nose_parametrized package in my project and @parametrized.expand decorator on class level. But I don't know how to use a parameter for my setUp class. Code looks like that: from nose_parameterized import parameterized …
Malvinka
  • 1,185
  • 1
  • 15
  • 36
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) …
1
vote
0 answers

How to initialize webdriver by parametrization

I'm new in pytest and probably I don't understand parametrizing as good as I would like to. My goal is to pass browser name while running test to tell pytest which webdriver I want to use. This is my code: conftest.py def…