Category "pytest"

Pytest: run teardown once for all workers using pytest-xdist

I have a pytest fixture that I need to run only once across all pytest workers. @pytest.fixture(scope="session") @shared # this will call setup once for all pr

ImportError: cannot import name 'ProductDetails' from 'pages.views'

I have written test case for views for details page. Here is below code I have written, When I am running Pytest in terminal it raising these error. My project

Parametrizing with class method, then calling that method with object

(pseudo-code) I have class Node with properties: class Node(WebElement): def __init__(self, element): super().__init__(element) ... @p

How to make qtbot select an item from QComboBox?

I'm trying to develop a simple test application (using pytest) that tests an interface with many PyQt5 components (QLabel, QLineEdit, QCheckBox, QRadioButton an

Bazel and py_test in sandbox - any way to define outputs?

I'm running multiple py_test() configurations on number of projects. Since there's a plenty of them, the default sandboxing mechanism seems convenient - tests d

Pytest: How to know which fixture is used in a test

Maybe I'm not "getting" the philosophy of py.test... I'm trying to re-write a bunch of tests for aws lambda code that receives events (webhooks with json payloa

flask test_client returns 404 for valid url

I've been writing an API and I want to test it. Get requests to API by requests are working well but when I want to test by test_client I have always received

Why does Pytest create a new class instance for each test method?

I was reading the Pytest documentation when I noticed a section titled "Grouping multiple tests in a class". There's a paragraph below with a caveat that each t

Pytest throws 'attempted relative import beyond top-level package'

I know this question has been asked before but i cannot seem to find a solution. This is my folder structure: folder_name/ __init__.py start.py src/

avoid pytest executing python script code during collection

I have it in my project that every python file that has executable python code directly in it, i.e. code that is not encapsulated in a class, will be executed b

How to configure pytest in FastAPI?

I'm trying to write some tests for my FastAPI -application. I have defined app in main.py like this: app = FastAPI(). I try to import this in my test test_api.p

python: clear / reset `@lru_cache` functool caching with every pytest testcase for undisturbed mocking

I combine mocking and caching in my code. The mocking is (kind of) random for each pytest as I do not know exactly, what will be returned in the real case. Henc

Pytest models not getting imported due Apps aren't loaded yet

nas_apps nas_apps -__init__.py -environments.py -settings.py -urls.py -wsgi.py -pytest.ini usecase1 -co

Mock Dependency classes in FastAPI

I have an api which is representative of the structure of: from fastapi import FastAPI, Depends, Request, APIRouter class SomeManager: def get_value_from

Using pytest with FastAPI + Tortoise : tortoise.exceptions.DBConnectionError: Can't establish connection to database

I have two postgres databases, one for prod and another for testing in "DATABASE_URI" and "TESTDATABASE_URI" respectively. The app seems to working perfectly, w

How can I skip authentication in a single test with a fixture in Fast API together with pytest?

I have built authentication similar to what is described in the documentation. So I have this dependency copied from there: async def get_current_user(token: st

How to fix "InternalError: variable not found in subplan target list"

I have a legacy Django project (django-1.1.29) and some tests in pytest (pytest-4.3.0), all running inside Docker. The database is PostgreSQL 10 and is a docker

How to mark individual parameterized tests with a marker?

I have been trying to parameterize my tests using @pytest.mark.parametrize, and I have a marketer @pytest.mark.test("1234"), I use the value from the test marke

Pytest-cov with Moto in list_stacks() from Boto3

I'm trying to create a test with pytest and moto that check if the StackStatus from the dictionary returned from the function list_stacks() (https://boto3.amaz

Why can't pytest-django find manage.py?

I have a project structure like this: setup.cfg integration_tests/ |----tests.py src/ |----manage.py |----my_django_app/ And a setup.cfg with this: [t