Skip to main content

All Questions

Tagged with
0 votes
0 answers
29 views

Django Internationalization test error:Couldn't retrieve redirection page

I wrote a blog project in Django,in some pages i used loginrequierdmixin to make sure user is loged in but in test i got error test: def test_get_profile_unauthenticated(self): response = ...
ParsaM's user avatar
  • 1
-1 votes
0 answers
28 views

FastAPI dependency is not getting overriden [SOLVED] [closed]

I'm trying to run some tests with pytest against the API but my dependency override is not working. The root app is in my 'main' file and the endpoints are in a 'routers' file. I also have a separate '...
Xcecution's user avatar
  • 1,085
0 votes
1 answer
30 views

How to test Amazon Athena queries

I have a rather complicated Athena query, which I would like to test on a local machine without connecting to Athena. I specified some mock data for testing purposes, and I was hoping that I could use ...
Amuoeba's user avatar
  • 716
1 vote
0 answers
24 views

mocking out imported objects in Python

Lets say there is a module headache that defines an object that is then imported and used by code I want to test: # defined in headache/__init__.py problem = Problem() then it's imported by Foo: # ...
solyd's user avatar
  • 792
1 vote
2 answers
64 views

How to mock sqlalchemy's async session?

Code snippet from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine engine = create_async_engine(url="") session_maker = async_sessionmaker(engine) How can I mock the ...
Michael Xia's user avatar
0 votes
0 answers
28 views

How to list all futures that are being polled inside specific event loop when running pytest?

I'm running multiple pytest tests. I have 1 specific test case, which works fine when executed alone, but when large amount of previous tests are being executed, this particular test gets stuck when ...
Grzegorz Limanówka's user avatar
1 vote
1 answer
24 views

Cannot mock the method in dependency module correctly in Python

Here is my project structure |-- project |-- util.py |-- main.py |-- tests |-- test_main.py In the main.py file I reference the function in util.py from util import rename def ...
hh54188's user avatar
  • 15.4k
1 vote
1 answer
132 views

Robot Framework is Automatically closing the browser

I am new to Robot and have this simple code from a tutorial. The code is supposed open chrome and visit the login page of this website. It does that, however, it closes the browser automatically. I've ...
User9123's user avatar
  • 755
0 votes
0 answers
40 views

Why python testing always import the file in another module implicitly

Current I have two files in the same folder, in the source file I import the dlt module # File: pipeline.py import dlt Another is a test file which import nothing from the source file yet: import ...
hh54188's user avatar
  • 15.4k
1 vote
1 answer
30 views

Django session in tests

everyone! I can't figure out how the sessions work in Django. I have a shop, an anonymous user's shopping cart is bound to session_key. The session key is taken from the request object. def ...
Андрей's user avatar
0 votes
0 answers
24 views

Why 'coverage' considers all of my class-based-views as tested?

I'm just learning django testing. When I use 'Coverage' module to check which parts of my code is tested, it considers almost all of class-based-views as tested while I have commented out all of my ...
mohsenof's user avatar
  • 109
0 votes
1 answer
33 views

AssertionError while testing forms.py in Django

I tried to test forms.py in Django which has LeadForm class. Here, is the models.py class Lead(TimestampedModel): """leads for LIVE courses""" course = models....
Keerthana Baskar's user avatar
-1 votes
1 answer
27 views

Flask unit test failing due to FileNotFoundError for private key file [duplicate]

I'm trying to run unit tests on a Flask application that utilizes public and private keys for JWT token generation. However, when running my unit tests, I'm getting a FileNotFoundError indicating that ...
KauaKing's user avatar
0 votes
0 answers
23 views

testing django oauth2_provider authentication endpoint

I need to test o/token endpoint of the oauth2_provider. I wrote the test in pytest. I think I considered every thing but I get invalid_client error. The code: factory: class UserApplicationFactory(...
Mosy Mosy's user avatar
0 votes
0 answers
47 views

How to parse step definition code for projects using Cucumber?

I'm working on a project where I want to evaluate how Behavior Driven Development is being used. I want to extract Gherkin steps from .feature files and match the underlying step definition code. For ...
Uncle Ben's user avatar
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=[&...
Андрей's user avatar
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 ...
DracoArtist's user avatar
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=...
eilchner's user avatar
  • 121
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: ...
h ca's user avatar
  • 27
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 ...
Gustavo Costa's user avatar
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 ...
Meronam's user avatar
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:...
Ramil's user avatar
  • 1
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&...
sixtyfootersdude's user avatar
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, ...
sceptre's user avatar
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
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 ...
sghgw's user avatar
  • 93
-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 ...
Daphne's user avatar
  • 1
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, ...
user2395059's user avatar
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 ...
Misto Shiawase's user avatar
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 ...
aka00's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
119