Skip to main content

All 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 ...
Miguel Montes's user avatar
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 (...
Leggy's user avatar
  • 155
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 ...
Виктор Валентинов's user avatar
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 ...
Hamza Abbas's user avatar
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): ...
ProxilityProblemSolver's user avatar
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: # ...
ningelsohn's user avatar
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 │   └──...
joegrammer's user avatar
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: ...
Saikat Karmakar's user avatar
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 ...
Chephen's user avatar
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 ...
JahKeem's user avatar
  • 11
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)...
Matias Ezequiel Miguel Rovedo's user avatar
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 ...
tyleax's user avatar
  • 1,674
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&...
c_sagan's user avatar
  • 502
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 ...
wjmccann's user avatar
  • 512
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/...
Angry bird's user avatar

15 30 50 per page
1
2 3 4 5
12