Category "pytest"

PYTEST - Is it possible to create the same fixtures more than one time?

I have some parameters coming from a JSON file, and some fixtures in my conftest.py I would like to iterate all the option scenarios from my list and create my

Error while loading the pytest module in Django project

I am trying to run pytest in a django project with it is showing me error of no module loading. I have created init.py in test folders, but that also not worked

Understanding pytest-django test arguments

What are 'rf' and 'user_context' parameters and when are they assigned? import pytest from rest_framework import status from rest_framework.reverse import rever

Multiple flask calls in single pytest having different databases

So I'm trying to test an endpoint in flask that I need to call multiple times in one test. The issue I am having is that on the second request the objects I pla

How to test async function using pytest?

@pytest.fixture def d_service(): c = DService() return c # @pytest.mark.asyncio # tried it too async def test_get_file_list(d_service): files = aw

How to patch local function of a variable?

I tried to write a test for this but I keep getting an error that the list is not callable. How can I patch nodes.items() so that items returns a list? # Get li

Why are the values yielded by a pytest fixture and a function called directly different?

In the code below, what I get is a generator object <generator object a at 0x7feb40b2d7b0> from playwright.sync_api import sync_playwright def get_playw

How to pytest that a decorator is assigned to multiple functions

I read somewhere on SO that you should not test the decorator but the functionality of the wrapped function. Nevertheless there might be a shorter way of testi

Pytest hangs indefinitely running tests after Selenium image update

A day ago selenium updated their standalone-images (https://hub.docker.com/search?q=selenium&type=image) and at the same time selenium 4.0.0 was released on

pytest (or unittest) not working when a source file has a dependency

I'm not sure why this is so difficult to get going, but I'm new to Python and I'm trying to get any unit test framework to run tests, but if I test a file that

FastAPI psycopg2 error when creating database for tests

I'm trying to test my database in my FastAPI app. from fastapi.testclient import TestClient from sqlalchemy import create_engine from sqlalchemy.orm import sess

In PyCharm using pytest integration, can print() output be suppressed for passed tests?

UPDATE: I've raised this with JetBrains. They have responded to say it's not configurable and merely a usability issue and not a bug in PyCharm. I've questioned

How to solve PytestConfigWarning: Unknown config option: DJANGO_ SETTINGS_MODULE error?

I am using django to build my website and I have used django-pytest to test my apps but I have got this error Note I am usign python 3.9 =======================

AttributeError: 'NoneType' object has no attribute '_with_attr' Brownie

I was following the freecodecamp smart contract course, i was in lesson 6 brownie Fund me/ when i was setting up my test it showed me the next error: platform w

How to do exact one-to-one match validation with pydantic model schema?

How can I exactly match the Pydantic schema? The suggested method is to attempt a dictionary conversion to the Pydantic model but that's not a one-one match. I

'Customize' short test summary info pytest

I'm starting to learn automated testing. When I run a test I want to get a specific text ('No Add to Cart button') on error of selenium NoSuchElementException I

Testing in pandas library: Why is function style chosen over class based testing?

Why is functional style testing facilitating testing compared to class based testing? Is this just additional library specific functionality or are there any ge

py.test: error: unrecognized arguments: --cov-report --cov=

I am running this test case command below py.test --cov-report term-missing --cov=pipelines/core/comp/plugins/abc/ --noconftest pipelines/core/comp/test/plugins

VSCode: how to interrupt a running Python test?

I'm using VSCode Test Explorer to run my Python unit tests. There was a bug in my code and my tested method never finishes. How do I interrupt my test? I can't

AttributeError: 'NoneType' object has no attribute '_with_attr' - Python running tests with pytest

My environment is : Python 3.9.9 Pytest 6.2.5 Brownie 1.17.1 I'm working on the test_fund_me.py from Patrick Collins' Smart Contract tutorial on Youtube; at thi