Questions tagged [pytest]

For questions about the pytest Python testing tool. Please also add the [python] tag for questions tagged with [pytest].

pytest
Filter by
Sorted by
Tagged with
-2 votes
0 answers
14 views

Database sur les test [closed]

I'm looking for existing examples of unit and integration tests in open-source projects that can be used to train an AI model. If anyone knows of such examples, please share them with me. I'm looking ...
chouitar mouad's user avatar
0 votes
0 answers
6 views

Mocking GraphCypherQAChain in Python unit test cases

chain.py ---------------------------------- from langchain.chains import GraphCypherQAChain from langchain_openai import ChatOpenAI from langchain_community.graphs import Neo4jGraph from langchain....
Saikat Bhattacharya's user avatar
0 votes
0 answers
13 views

Temporal Postgres Database with sys_period

I am building a test database for unit testing. I have a model like this class MyObject(Base): __tablename__ = "my_object" id = Column(UUID, primary_key=True) sys_period = ...
magerine's user avatar
-1 votes
0 answers
18 views

VSCode and Pytest is not printing to Debug Console [closed]

I have already read many articles in saying about the problem of not printing to DEBUG CONSOLE on VSCode. IN one of my project, everything works ok, printing to the output. In the other one, with same ...
p.magalhaes's user avatar
  • 7,936
0 votes
1 answer
12 views

Can I get access to a pytest hook to inject my logic AFTER the junit XML results file has been created?

From reading the docs I see that the latest hook after a test class has completed is pytest_runtest_logfinish. However, when I implement that hook and use the debugger, I see that the XML file (...
Leggy's user avatar
  • 147
1 vote
1 answer
25 views

Unable to select options from dropdown Admin or ESS for Orange HRM site for UserRole

I'm new to Selenium and python and am creating a framework using pytest from scratch. The URL https://opensource-demo.orangehrmlive.com/web/index.php/auth/login The username and password is documented ...
vishal deshpande's user avatar
0 votes
0 answers
15 views

Mock or stub a QEvent?

Is there a way to mock a QEvent and pass it as a parameter? I have a test like this which I want to include: def test_table_resize_event_sets_column_widths(): table = results_table_classes....
mike rodent's user avatar
  • 14.8k
0 votes
2 answers
27 views

Unit testcase with parameterized class fixture in Pytest framework is throwing error

I am new to pytest framework. I need to create a testcase with a parameterized fixture on a class. I have created the testcase as below. But it is throwing an error saying: TypeError: TestClass....
Python Developer's user avatar
1 vote
0 answers
20 views

E bot.ftech_channel raises error with pytest AttributeError: '_MissingSentinel' object has no attribute 'is_set'

I have a discord bot which needs to fetch guild and channels. If I get none from bot.get_guild(), I try to fetch_guild through api. The code looks something like this: async def get_or_fetch_guild(...
Aarti Joshi's user avatar
0 votes
1 answer
28 views

Pytest - parametrizing a test method from a fixture

I have a scenario where there is a fixture (in conftest.py) that reads data from a file and returns a dict. I have to use this dict to parametrize a test method. Can someone help me with this? The ...
Ananthakrishnan K's user avatar
1 vote
1 answer
15 views

Pytest two async functions both with endless loops and await commands

I am unit testing a python code. It has an asyncio loop. The main two functions in this loop have endless while loops. I have tested the non-async parts of the code. I am wondering what is the best ...
AmirKamali's user avatar
0 votes
1 answer
34 views

Pytest and PyCharm: how to get <Click to see difference> always?

There is a difference in the assert output of Pytest in PyCharm depending on if function with assert in the same file or in the another file. Let's consider an example. tmp.py: from utils.tmp_1 import ...
Diggy's user avatar
  • 133
0 votes
0 answers
17 views

pyautogui for multiple image upload

# click on Add Photo button captureinpsection.find(CaptureInspection.addPhotoButton).click() # List of file names file_names = ["Ceiling-1.jpg", "Ceiling-2.jpg&...
Lisa's user avatar
  • 97
0 votes
0 answers
14 views

Mock TCP-RX/TX in python code for testing in CI/CD pipeline

My python-based project contains three different modules, a RX-module, a processing module and a TX-module. Both RX and TX communicate via TCP/IP with their external counterparts. However, there are ...
arc_lupus's user avatar
  • 4,028
0 votes
1 answer
24 views

Flask pytest not able to find module

I have trawled through past posts regarding Flask import issues but I'm struggling to implement them on my particular case. Essentially, pytest cannot recognise any relative imports I make into my ...
Sidra I's user avatar
1 vote
0 answers
25 views

Record video of test execution in selenium python pytest

I have this code written in my conftest to record video of test execution, this works fine in a machine with a screen for e.g a PC. But as soon as it is run through Jenkins in a pipeline on a VM it ...
Sehaj Paul Singh's user avatar
0 votes
1 answer
27 views

Mocking db connections and return values inside a flask route

I have the following flask app route: # routes.py from flask import jsonify from app.utils.db import db_connection, db_query @api.route("/some/route", methods=["GET"]) @auth def ...
says's user avatar
  • 115
0 votes
0 answers
30 views

Unable to run GraphicalUnitTest in github-action runners: macos

Summary of situation I'm developing kivy app to run in 3 major OS (linux, windows, mac) and currently writing simple unit tests with the GraphicalUnitTest class in a github-action: class ...
qlrd's user avatar
  • 1
0 votes
1 answer
29 views

How to access a fixture inside non-fixture function in pytest

I tried to pass the list of test data file paths as a command line argument. However, I have ended up with following code block: From conftest.py file: import json from pytest import fixture def ...
Aziz Kavas's user avatar
0 votes
2 answers
41 views

Pytest command doesn't work without specifying python -m pytest

My Project setup is in VS code and is as good as any setup. When I run python -m pytest testfile.py, everything runs smoothly. But when I try pytest test_file.py, it raises: ModuleNotFoundError: No ...
VishwasR Vibhu's user avatar
0 votes
0 answers
15 views

GraphQLResolveInfo' object has no attribute 'field_asts'"

So I am using graphene-django==3.1.2, which didn't let me importfrom graphql import ResolveInfo . Therefore, I used from graphql import GraphQLResolveInfo as ResolveInfo However the error I see now is ...
Jolly's user avatar
  • 164
-1 votes
0 answers
17 views

Using Pytest and Hypothesis for Visualization [closed]

I am working on image augmentation using the albumentation library ,also i am writing test cases for each like rotate should be within 50 - 90 degree,Blur=blur_limit min: 3 max: 99,How do i visualize ...
asif khan's user avatar
0 votes
0 answers
8 views

Celery pytest fixtures with embedded delay calls

I have an example project for celery test fixtures my directory structure: src/celery_tasks.py test/test_example.py test/conftest.py src/celery_tasks.py contains: from celery import Celery app = ...
Connor's user avatar
  • 615
1 vote
2 answers
36 views

Using the "@pytest.hookimpl(tryfirst=True)" results in the following AttributeError "generator object has no attribute skipped"

I am currently making a self contained html report using pytest-html and selenium. This is the method btw: @pytest.mark.hookwrapper def pytest_runtest_makereport(item): """ ...
Luis's user avatar
  • 13
0 votes
0 answers
27 views

pytest- unable to access fixtures in a parent directory

I have following dir structure and everything is running under virtual env. - proddir |- testdir |- test_feature1 |- test_create.py |- conftest.py |- libdir ...
sbm3's user avatar
  • 1
0 votes
1 answer
11 views

Unit testing Asyncio ensure future

I have an async method which is basically used for making callback requests. I want to test this method and write unit tests. But I'm facing some issue while doing so. Can anyone point me to the right ...
PSN's user avatar
  • 2,436
0 votes
1 answer
21 views

Consuming an iterable/list/generator of dynamically loaded pytest fixtures

I'm trying to create a dynamic fixture loader for pytest that does some work after the value is yielded to the test. In the beginning, I didn't need to do anything that complicated, so I just returned ...
brandonscript's user avatar
0 votes
0 answers
18 views

Difference between regular def and lambda for reversing a url in django test [duplicate]

Consider the following two examples and explain to me why they are different (they look the same to me but the lambda does not work as expected) Using the lambda, I keep getting the following error: ...
asus's user avatar
  • 1,607
0 votes
1 answer
51 views

Pytest reports missing lines in coverage for imports and constant assignments

I'm baffled by differences in coverage behavior for different files in my project and hope someone will please suggest how to debug this more effectively than I am doing now. This is basically the ...
chrisinmtown's user avatar
  • 3,998
0 votes
1 answer
31 views

Pytest : access addoption arg outside tests

Goal : Access addoption argument in setup_class (or outside test method / fixture) Context : I have a test framework that require a "mode" to be initialise, this mode can be set through ...
shined day's user avatar
0 votes
0 answers
21 views

CS50P unit testing problem set 5(back to bank) whereby testing manually works but the check function of cs50p doesnt check code [closed]

i am doing a problem set exercise where i am suppose to test my code that i had written before i have a problem where by check50 does not check my code and it returns an error but when i manually ...
John Lambert's user avatar
1 vote
1 answer
39 views

Increasing test coverage for files I didn't write

I have written a python program that calculates various statistical values of a given list of integers and the range of values. Now, I am trying to write a test file for the program that can achieve &...
Austin's user avatar
  • 49
0 votes
1 answer
30 views

how to mock s3 using pytest? Unittest script calls actual function instead of mocking it?

I'm trying to test a function that should mock s3 resource but instead it tries to call the actual function. Here is my code to test. import sys import requests import json import pandas as pd import ...
47sahilone's user avatar
1 vote
2 answers
40 views

How can I use pytest to see if a class attribute attribute exists in python?

I'm a tech teacher, trying to learn how to use pytest to create specialty koans for my students to learn python syntax. (If you check a previous question, I have details as to what's going on here.) I'...
KTheTechTeacher's user avatar
1 vote
0 answers
25 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
-1 votes
1 answer
27 views

How to find the text from a label in selenium pytest

I've a requirement to capture the payment ID from the text in an element using Selenium, python, pytest UI. The text is in the form, "Payment 3022594". I was trying something like this. ...
Ram's user avatar
  • 307
0 votes
0 answers
8 views

Python patched function mock called_with compares with modified data -- best way to fix?

I have a function (validate.py): def _validate_data(data: dict[string,Any]): pass It's not implemented yet so its a stub. I want to verify that another function calls this one with an empty dict ...
Edward Strange's user avatar
0 votes
1 answer
34 views

Adding fixtures to marked tests

I write tests using pytest. I need to do certain things before and after some tests. How can I automatically set the some_fixture to the test function if it is marked with some_marker? To implement ...
Kirill Lekhov's user avatar
0 votes
2 answers
31 views

Pytest assertion problem for HTTPException: 500

I am having problem about testing a very simple FastAPI end-point and not able to assert HTTPException: 500. This is my endpoint get AuthenticationRequest from client to get a token from an external ...
crowley's user avatar
  • 39
-1 votes
1 answer
25 views

Pytest - Mocking a single line in python function

I'm doing tests for my function but I have one line calling my config mongo uri path and I need to mock this one but I don't know how. def get_indexes(collection, database, criterias): file = ...
Morgane FLAMANT's user avatar
0 votes
0 answers
22 views

Qodana Code Coverage with pytest and Github Actions - Qodana does not show code coverage

I'm using Qodana for a project where the backend is written in Python. I'm using GitHub Actions to interact with Qodana. I'm trying to set up code coverage metrics in the Qodana scan report, but I'm ...
Darnol's user avatar
  • 1
-1 votes
0 answers
27 views

What do I do if pytest is collecting 0 items but has 1 error?

I tried running a test_trial.py file that tested a function from a trial.py file. In vscode, pytest is working as intended but in the powershell of windows, it tells me that pytest collected 0 items / ...
user22336656's user avatar
0 votes
0 answers
24 views

Python tests failing due to testcontainers-postgres connection refused

I am trying to run integration tests by using PostgresContainer from the testcontainers module in Python. These tests are part of the CI workflow on Github Actions but they are failing due to the ...
Asad Amir Khwaja's user avatar
0 votes
0 answers
27 views

How can I fix 'greenlet_spawn has not been called' error when using fixture and SqlAlchemy?

Pytest + Async SqlAlchemy + async_sessionmaker not working repo: https://github.com/gabszs/CV-API error -> sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only(...
Gabriel Izaac Norberto de Carv's user avatar
0 votes
0 answers
26 views

Not able to run pytest

Can someone help me. I have installed pytest however when I try to run it from command line, it does not work. See pic. I read documentation but it just says to use the keyword pytest followed by name ...
Joseph Ochoa's user avatar
0 votes
1 answer
24 views

Selenium Pytest ValueError: setup did not yield a value

I have this test suite (using selenium python pytest) named "test_invoice.py" which has several tests inside it. Similarly I have other test suites in other python files named "...
Ram's user avatar
  • 307
0 votes
0 answers
18 views

Handling shared state in pytest fixtures with different scope

I'm facing an issue with pytest where tests are interfering with each other due to the shared state in a fixture with different scopes (function, class, session). I've created a minimal reproducible ...
Olivier D'Ancona's user avatar
2 votes
2 answers
59 views

Use caplog in autouse fixture in pytest

I'd like to wrap all my tests with a fixture where the logs logged with loguru are checked for error messages. I tried this: @pytest.fixture(autouse=True) def assert_no_log_error(caplog): yield ...
lefli's user avatar
  • 21
0 votes
0 answers
13 views

Pytest mock ring.redis decorator

Below is my class implementation: class Person: def __init__(self, n): self.n = n self.foo = self.fun() @ring.redis(redis.RedisClient, coder="json") def fun(self): ...
Ridz's user avatar
  • 1,410
0 votes
1 answer
21 views

The websocket freezes in pytest on receive_text()

I have a working old version of the code, where the test completes successfully, after I updated the code - the test just started hanging on the receive_text, I have no idea why except ...
ZHMESHNECK's user avatar

1
2 3 4 5
206