Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
61 views

@transaction.atomic def deposit(user: User, account_number: str, amount: float) -> None: account = get_object_or_404( Account.objects.select_for_update(), account_number=account_number, ...
Jueun's user avatar
  • 11
2 votes
2 answers
110 views

I am coding a FastAPI app with async functions. My issue is, I can't properly mock async function with the mocker.patch from pytest-mock nor with AsyncMock from unittest. The issue is, I can't test ...
Mister Balise's user avatar
1 vote
1 answer
64 views

I have a custom class in the file MyClass.py class MyClass: def __init__(self): self.fetched_data = False def get_data(self): self.fetched_data = True ...
DwightFromTheOffice's user avatar
2 votes
1 answer
44 views

We can check if a unittest.mock.Mock has any call with some specified arguments. I now want to test that some of the arguments are correct, while I do not know about the other ones. Is there some ...
502E532E's user avatar
  • 581
0 votes
0 answers
23 views

In odoo 17 I need to use unitest.mock to mock the return value of a function The function is called cfdi_cancel. It is located in mymodulename module, inside that module is the 'models' folder, inside ...
Ernesto Ruiz's user avatar
1 vote
1 answer
42 views

I am trying to call four decorators on my unit tests to easily allow code to be refactored: pytest.fixture, unittest.mock.patch, pytest.mark.parameterize, pytest.mark.asyncio. I currently am calling ...
Addi O's user avatar
  • 21
1 vote
1 answer
106 views

I have an app/main.py for FastAPI which does: import qdrant_client as QdrantClient ... qdrant_client = QdrantClient(url=...) qdrant_client.create_collection(...) ... app = FastAPI() ... @app.get(&...
Clovis's user avatar
  • 4,483
-1 votes
1 answer
70 views

A minimal working example is available at https://github.com/rgaiacs/django-mwe-magicmock. When using Django, I use Model.clean() to validate the form submitted by the user. During the validation, ...
Raniere Silva's user avatar
1 vote
0 answers
32 views

Running docker compose -f docker-compose.local.yml run --rm django pytest ./project/app/ the following test passes perfectly, meaning patch method is being used @patch("project.app....
Nadav's user avatar
  • 634
1 vote
1 answer
188 views

I'm trying to write a test for a class which performs a pandas apply. Here's a simplified version: import pandas as pd class Foo: def bar(self, row): return "BAR" def apply(...
olives's user avatar
  • 118
-1 votes
2 answers
56 views

I have a file that looks roughly like this: bar.py from foo import foo # function that returns an int from dog import Dog dog_foo = 4 * foo() my_dog = Dog(dog_foo) ... I want to test that the ...
user7097722's user avatar
0 votes
2 answers
75 views

How would I assert that this function wrote to those files in tests? def write() -> None: with open('./foo', 'w') as f: f.write('fooo') with open('./bar', 'w') as f: f.write(...
sezanzeb's user avatar
  • 1,227
3 votes
1 answer
56 views

I've tried multiple ways and just can't get the result I'm looking for. It seems like a lot of questions use a different type of mocking with the whole @patch decorators but I've been using this more ...
Darius Fiallo's user avatar
2 votes
1 answer
124 views

I am using Python 2.7 for a coding project. I'd love to switch to Python 3, but unfortunately I'm writing scripts for a program that only has a python package in 2.7 and even if it had one in 3 our ...
Réka's user avatar
  • 145
1 vote
1 answer
112 views

I'm trying to figure out how to mock matplotlib's plt.savefig inside a class to test if my GUI's button is actually saving a figure. For simplicity's sake, I will not include the GUI, but only the ...
DracoArtist's user avatar
-1 votes
2 answers
85 views

I have a test that intermittently fails during automated builds so I want to add some retries to my tool. However, I'm not sure how to force the tool to fail and verify that it has retried before I ...
jon_two's user avatar
  • 1,278
0 votes
1 answer
80 views

I'm trying to obtain different responses by each call on a Mock by using the side_effect attribute. However, I'm obtaining the first one each time. I would like to ask if I can get any help on it. ...
HouKaide's user avatar
  • 363
0 votes
1 answer
22 views

I have Processor class: class Processor: def __init__(self, session_provider): self.session_provider = session_provider def run(self): ... self.session_provider....
KwarcPL's user avatar
  • 75
0 votes
3 answers
63 views

Trying to unittest a method that receives a class as an argument but unsure how to mock it right I am trying to unittest this method ` def get_local_path(p4_path, p4): if p4_path.endswith('...'): ...
Craig L's user avatar
1 vote
0 answers
128 views

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
40 views

I am using unittest.mock to test my Django application. The set-up is the following: I want to test a function foo foo uses a method X which is a constructor from an external package X is called in ...
kenshuri's user avatar
  • 542
1 vote
0 answers
50 views

I have these two classes: one.py class One: def __init__(self) -> None: pass def startS(self): self._doS() def _doS(self): print("Inside doS ...
tatti's user avatar
  • 11
0 votes
1 answer
52 views

I'm using side_effect for dynamic mocking in unittest. This is the code. // main functionn from api import get_users_from_api def get_users(user_ids): for user_id in user_ids: res = ...
user avatar
0 votes
1 answer
74 views

I'm going to mock a Python function in unit tests. This is the main function. from api import get_users_from_api def get_users(user_ids): for user_id in user_ids: res = get_users_from_api(...
user avatar
0 votes
0 answers
62 views

I want to make a unit test for the following code. But i can not try to correctly mock the cursor of my mocked connection. In the unit test, I mock first the connection of my tested code. But the ...
Thomas Campos's user avatar

1
2 3 4 5
8