Skip to main content

All Questions

Tagged with
0 votes
1 answer
59 views

pytest fixtures in nested Classes

I have written the following testcase using pytest. import pytest data_arg = ["arg1", "arg2"] class TestParentClass1: @pytest.fixture(scope="class", params=data_arg,...
Shreyansh Jain's user avatar
1 vote
0 answers
30 views

How to use multiple API modules in a single testing file?

Disclaimer: first Stack Overflow post, and very new to pytest. I'm a part of a very new QA team in the company. Right now we are focusing on creating initial tests for various Sync APIs (most of them ...
Ariel Agranovich's user avatar
0 votes
2 answers
548 views

Setting project with selenium and pytest

Recently I have started a new project with Selenium and Pytest and I'm not sure what is the best way to set up the driver and the general structure of the project. I have set up the driver inside ...
Biedrzu's user avatar
  • 15
-1 votes
1 answer
39 views

Two function scope fixtures are run in reverse order

I have such a problem, I have a fixture called appclient which is session scope, its body looks like this: @pytest.fixture(scope='session') def appclient(): yield SomeClass() then I have two fixtures ...
cmdulek98's user avatar
1 vote
1 answer
2k views

pytest mark parametrize a fixture

I want to test a function get_xyz(a, b, foo), where foo is a class. A foo_fixture is defined in a conftest.py like so: @pytest.fixture() def foo_fixture(): return Foo() The fixture simply returns ...
des224's user avatar
  • 139
0 votes
2 answers
356 views

Fixture found but not called

I am testing a bot in python-telegram-bot using pyrogram to simulate inputs. I have to set a cryptography key in my environment so the code being tested can access it. I tried to accomplish this ...
João Pedro Martins de Paula's user avatar
0 votes
1 answer
533 views

pytest fixture runs for class instead of each tests separately

Could you explain to me please why fixture with scope function(which is supposed to run anew for each test) runs for the whole test class? @pytest.fixture(scope="function") def ...
Alice Rossi's user avatar
0 votes
1 answer
2k views

How to pass different values to a pytest fixture (which calls a func. having arguments) using parametrization?

I am pretty new to Pytest and going through the pytest fixtures and parametrization for API tests. I am trying to create a fixture that creates a POST method request using a predefined function (the ...
Saad Pasha's user avatar
0 votes
0 answers
139 views

How to write fixture files for testing models

I want to test my database and Django app via fixtures and Testcases. The problem is that I cannot find any information on how to create fixtures, especially regarding relationships. I tried in the ...
ProtoSlayer's user avatar
5 votes
2 answers
5k views

Set a class attribute in pytest fixture

I'm making a test class for pytest, I want to set a class attribute a that will be used for several test methods. To do so, I used a fixture set_a, which is launched automatically autouse=True, and ...
LeoGlt's user avatar
  • 198
3 votes
1 answer
1k views

How to get the count of fixture run in pytest test

I am inserting the data in DB and I make an API call to the endpoint I am testing with row id. I have a parameterized test which runs the fixtures multiple times. @pytest.mark.parametrize( "...
JD Solanki's user avatar
0 votes
1 answer
232 views

Parameterized test using fixture with yield. Fixture doesn't run cleanup code after yield

I have a fixture that inserts the data in DB and removes it after yield @pytest.fixture def add_marketplace_ts(session: Session): marketplace = Marketplace( name="themeselection",...
JD Solanki's user avatar
0 votes
2 answers
475 views

How to load and use iterable data object in Pytest?

I'm writing my first code test ever for the data processing step of an ML project using Pytest 6.2.5. The code is made up of some functions (I haven't written a class). I want to load some test data ...
Sasan's user avatar
  • 15
0 votes
1 answer
2k views

Why is my conftest fixture is not applying to all FastAPI tests?

conftest.py import pytest from ...main import app as starter from fastapi.testclient import TestClient @pytest.fixture(autouse=True, scope="module") def client(): client = TestClient(...
Justin Reddick's user avatar
0 votes
0 answers
43 views

override autouse=True pytest fixture [duplicate]

I have a pytest fixture which I need to use in almost every test I write: # fixture to mock server response # autouse=True means that this fixture is included in ALL tests by default @pytest.fixture(...
mareoraft's user avatar
  • 3,844

15 30 50 per page