Skip to main content
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
0 votes
1 answer
108 views

I want to do a unittest with pytest for this method: class UserService: @classmethod async def get_user_by_login(cls, session: SessionDep, login: str) -> Optional[User]: sql = ...
Mister Balise's user avatar
2 votes
2 answers
115 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
0 votes
1 answer
75 views

I have a configuration module, config with data config.data where I want to add a value for testing. Ideally, I want to use mock.patch.dict as a context manager because the value is a class attribute ...
KSS's user avatar
  • 179
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
1 vote
1 answer
106 views

I am implementing a test for a function func1a() in module1.py using mocks. The function func1a() calls: one function from module2.py: func2a() one function from module1.py: func1b() It appears that ...
fbas's user avatar
  • 13
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
1 answer
114 views

I have a scenario where I create a git.repo.base.Repo object in a "someFile.py": def someFunction(): //some part of code repo = Repo(path) repo.head.reference = repo.commit(...
Shiva Shukla's user avatar
0 votes
0 answers
30 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
0 votes
1 answer
70 views

I always thought that you could mock a method on a class only when the class it is coming from is not instantiated in the code under test. And if it is you have to mock the class (just as you have to ...
Nemelis's user avatar
  • 5,562
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
0 votes
1 answer
33 views

I have code with below functionality src/client.py class Client1(object): def foo(self, t): return f"foo-{t}" def get_foo(self, type): return self.foo(type) src/...
uday8486's user avatar
  • 1,423
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
0 votes
1 answer
132 views

Is it possible to declare a local variable before it's imported? For example to get this code to run as expected: # a.py # do magic here to make b.foo = "bar" import b b.printlocal() # b....
Brett S's user avatar
  • 589
-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

15 30 50 per page
1
2 3 4 5
���
26