All Questions
3,541
questions
1
vote
1
answer
28
views
DRF test user sign-in, error inactive user
I have view for authentfication:
class UserViewSet(viewsets.ViewSet):
@method_decorator(sensitive_variables("password"))
@action(url_path="sign-in", detail=False, methods=[&...
0
votes
0
answers
40
views
"AssertionError: Expected 'show' to have been called once" when trying to mock plt.show()
I am currently trying to design some tests to run with pytest for a GUI. The GUI has a button that plots a graph on click. I want to make sure the button does indeed generate a graph. At this stage, I ...
2
votes
0
answers
29
views
Changing the scope of a pytest fixture to a larger one for a single module
I have a pytest fixture defined in conftest.py that looks like this:
@pytest.fixture(scope="function")
def setup_multiple(create, delete):
@contextlib.contextmanager
def f(type, num=...
0
votes
0
answers
11
views
How to get pitest-bdd to run a directory of .feature files against a single Python test script
Sorry i am new to to pytest-bdd and am having trouble finding resources on how to run a directory of .feature files against a single Python test script.
Example of one of these feature files:
Feature:
...
0
votes
1
answer
46
views
Mock patching an endpoint unittest that makes several requests to third party
I have a single endpoint written using django ninja. This endpoint executes a crawler that performs several requests. The sequence of requests has 3 different routines depending on whether or not the ...
0
votes
1
answer
33
views
@pytest.mark.parametrize for function that returns two values
I have a function that takes a pandas DataFrame (it is important that this specific DataFrame, that goes as an argument into the function, has no column names) and produces a DataFrame with column ...
0
votes
0
answers
25
views
How to compare in Python to TypeError using assert? [duplicate]
I write tests using Assert. How do I compare to TypeError ?
Function
def calc_of_the_cost_of_delivery(distance: int, size: str, fragility: bool, workload: str) -> int:
....
if distance > 30:...
1
vote
2
answers
47
views
Pretty print why two objects are not equal
When using pytest, I get nice pretty printing when two objects are not equivalent:
Expected :Foo(id='red', other_thing='green')
Actual :Foo(id='red', other_thing='blue')
<Click to see difference&...
0
votes
0
answers
42
views
Python unittest how to mock function which external function is defined in __init__.py
I would like to test my_func2 that is calling my_func1. I would like to mock my_func1, but I don't know how can I do it when my_func2 is imported in my_package.__init__.py. When I delete that import, ...
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
0
answers
29
views
How to test a CLI app with Typer and Questionary?
I have created a CLI app using Typer in Python. Among other things, it should be possible to create new records. For querying the individual properties, I have used the Questionary package. The CLI ...
-3
votes
1
answer
61
views
Find a word with three consecutive double letters using Python
This is a question from Think Python: How to Think Like a Computer Scientist by Allen B. Downey
Give me a word with three consecutive double letters. I’ll give you a couple of words that almost ...
0
votes
0
answers
20
views
Testing a Python package dependent on user input credentials
I maintain a Python package for other data scientists and analysts in my company, which simplifies access to S3/Hive/Trino. The package works by taking their credentials, storing them using keyring, ...
0
votes
1
answer
79
views
Use multiple AsyncClients with Pytest for Integration testing
I want to use two different httpx clients one which interacts with the actual database and other which interact with test database. But for some reason all the transactions happen on the actual ...
0
votes
0
answers
36
views
pytest how to implementation a plugin to execute by every directory
My project struct like
.
├── test_dir_1
│ ├── conftest.py
│ ├── test_case_1.py
│ └── test_case_3.py
└── test_dir_2
├── conftest.py
└── test_case_2.py
conftest:
import pytest
from loguru import ...