Reuse function as pytest fixture

I have a function in my code that is being used by fastapi to provide a db session to the endpoints: def get_db() -> Generator[Session, None, None]: try: db = SessionLocal() yield db finally: db.close() I want to use the same function as a pytest fixture. If I do something like the following, the fixture… Read More Reuse function as pytest fixture

Defining an Array in the fixtures and utilizing it in the main test case. Cypress Fixture throws a Type Error?

I am trying a test case with the help of the fixtures in Cypress. I have got the userdata.json folder under the ../cypress/fixtures folder. When I try to run the test I always get this error TypeError Cannot read properties of undefined (reading ‘assets’) Please find the code and other details here: The .json file… Read More Defining an Array in the fixtures and utilizing it in the main test case. Cypress Fixture throws a Type Error?

Test is not executed when pytest.fixture is used

I have a simple Python library, for which I use the following command to run tests: python setup.py pytest The following test works as expected: def test_out(): assert 1 == 2 Test result: platform linux — Python 3.10.4, pytest-7.1.2, pluggy-1.0.0 rootdir: /media/drive2/src collected 1 item tests/test_error.py F However, when @pytest.fixture is added, the test is… Read More Test is not executed when pytest.fixture is used

Fixture not found pytest error is being displayed when I run my test

Here are my conf.py, baseClass.py and actual test file (test_e2e.py). Can you please check and let me know what is wrong in my code. Looks like everything is fine but still my test is not running and showing ‘fixture not found’ error. conf.py file import pytest from selenium import webdriver from selenium.webdriver.chrome.service import Service @pytest.fixture(scope="class")… Read More Fixture not found pytest error is being displayed when I run my test

Cypress fixtures – Cannot read properties of undefined (reading 'data')

I’m trying to use fixtures to hold data for different tests, specifically user credentials. This is an example of the code. When it gets to the second test I’m getting ‘Cannot read properties of undefined (reading ‘data’)’. Any ideas why and how I can get around that? Is that wrong? before(function () { cy.fixture(‘credentials’).then(function (data)… Read More Cypress fixtures – Cannot read properties of undefined (reading 'data')

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(starter) return client test_main.py import pytest @pytest.mark.unit def test_root(client): response = client.get("/") assert response.json() == {"message": "Hello Bigger Applications!"} test_router.py import pytest @pytest.mark.unit class TestHelloRouter: def test_hello(client): response = client.get("/hello") assert response.json() == {"message": "Hello Router!"}… Read More Why is my conftest fixture is not applying to all FastAPI tests?