All Questions
177
questions
0
votes
0
answers
44
views
Django Token authentication failure: Authentication credentials were not provided
I am working on the user logic of my Django project. Despite the fact that logout (using session cookie authentication) works perfectly fine in the browser, it is not working during testing for some ...
0
votes
1
answer
21
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 (...
0
votes
0
answers
45
views
Coverage.py does not mark some statements as "hit" even though they are actually covered
I have a problem when using coverage.py. I am testing a FastAPI application and cannot get to 100% test coverage due to that. I also cannot share the code, because it is a business logic and therefore ...
6
votes
2
answers
92
views
How can I run code for Python testcase in VS Code?
When I ran this code in VS Code, it gives msg that "no testcase ran in 0.2s". So, How can I ran testcases in VS Code.
import pytest
from selenium import webdriver
from time import sleep
from ...
0
votes
0
answers
44
views
Using pytest for OOPS where one class calls another and calls another
I am a noob at writing unit testing and I have not been able to find the answer anywhere for the following purpose
class xLoader:
def __init__(self, config, request_id,logger, mongo_obj,data_in):
...
1
vote
1
answer
77
views
Why is my phyton mock only working with a specific way of import?
I have a utils class that besides other stuff has a function to get an id:
# utils.py
def get_id():
return ...
Also, there is another class, lets say its about cars, that uses this function:
# ...
0
votes
1
answer
34
views
python unittesting - functions depending on other modules
Is there a "correct" way to write unit tests for functions that rely on non-local functions (multi-module dependency tests).
e.g.
.
├── src
│ ├── main1.py
│ └── main2.py
├── tests
│ └──...
1
vote
1
answer
77
views
Wrong filed value in pydantic model
This is my pydantic class
class UploadResult(BaseModel):
reference: str
tag_uid: Optional[int] = Field(default=None, alias="tagUid")
class Config:
...
0
votes
1
answer
39
views
How do I return the function name of a class method being passed in as an argument?
I have a class called bio_seq with a class method called transcribe() and I am doing an exercise to create my own unit tests. I have created a function called unitTest() such as below so I have a ...
1
vote
0
answers
30
views
Python Selenium: How to dismiss a pop-up ad? [duplicate]
I am trying to automate a bunch of testcases that test all the input errors of a website and every test case works individually but when I run all testcases then I met with pop-ads every time and I ...
1
vote
0
answers
21
views
How can I test async code in with two asyn with sentences?
Im having a headache trying to test this code
pool = await session_pool()
async with pool.acquire() as conn:
async with conn.cursor() as cursor:
res = await cursor.execute(sql)...
0
votes
0
answers
32
views
How to fail unittest test suite even when all test cases pass
I am using python unit test framework to run automated test cases. Currently I want to have the ability to fail the test suite if a condition is not met even if all the test cases pass. I want the ...
0
votes
0
answers
136
views
pytest run using threads causes future tests to fail
I have a pytest class that sets up a server in a separate thread before each tests via setUp() like this:
def setUp(self):
host = "localhost"
port = 13620
scheme = "grpc+tcp&...
2
votes
1
answer
988
views
How to make PyTest use the `conftest.py` of a parent directory
I am working on a suite of tests for a project that were not written by me. The way they were set up is as follows
root/
conftest.py
testType1/
a.py
testType2/
etc.
The file a.py is ...
1
vote
1
answer
437
views
Pytest: pytest.ini file in subdirectories
Let's consider my current directory is /folder.
There is pytest.ini file in /folder/sub/.
There is a test_file.py and 'test_file1.py inside /folder/sub/.../tests/.
Now If I try to run pytest /folder/...