Skip to main content

All Questions

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
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
0 answers
64 views

AssertionError: PermissionDenied not raised

I'm new to testing in django , i'm trying to test a view that raises PermissonDenied when the test user is not authenticated , this is part of the view code @login_required def files_raw(request): ...
Wael's user avatar
  • 1
0 votes
0 answers
74 views

Unit testing in Python on a function that doesn't have a return value? Is including test-specific code in a function bad practice?

I am writing a mock-up Auction site in Django as part of my self-learning to code. I'm at the point where I'm learning to write tests for my software but I've encountered the problem where a number of ...
RockBass's user avatar
0 votes
1 answer
66 views

Django Ignoring TestCases

There are loads of questions with this issue, but whatever I try, it just doesn't want to work. This is the file structure of my project. As you can see, all directories have an init file. Here is ...
domjanzsoo's user avatar
0 votes
1 answer
22 views

How to mock test a function inside save method

I want to send an email each time the status of an object was equal to 13. def save(self, *args, **kwargs): from user_profile.models import SopResumeBuy if skip_sop_resume := kwargs.get('...
Hamedio's user avatar
  • 111
1 vote
1 answer
153 views

Django tests freeze when running async Celery tasks

I'm trying to create unit tests in Django, that tests the Celery tasks and whether or not the task creates the objects from the CSV data i give it. For some weird reason my tests freeze when calling ....
Zameezy's user avatar
  • 21
0 votes
1 answer
77 views

How to generate Django / Python Test for view with LoginRequiredMixin and UserPassesTestMixin

I am trying for some time to test a view of mine that I have protected from access via LoginRequiredMixin and UserPassesTestMixin. Unfortunately I do not manage to write the appropriate test. here is ...
gomez_'s user avatar
  • 123
0 votes
1 answer
1k views

AttributeError: 'HttpResponse' object has no attribute 'render'

anyone know why this error is happening? i've been running the same line for my other tests and only this one is returning an error both lines in test_coverageReturnSuccess + ...
akira's user avatar
  • 83
0 votes
1 answer
244 views

How can I unit tests for this Django Form

I do coverage report and there are many place that not cover, do you have any idea how to I write test for th? this views.py was not cover def addreview(request, u_id, shop_id): url = request.META....
dxxper's user avatar
  • 1
1 vote
0 answers
631 views

How to preserve database table between tests in django?

How to preserve the database entries between tests in Django testing? python3 manage.py test tests --keepdb --keepdb preserves the database but not the table. The tables get flushed between the tests....
PolarBear10's user avatar
  • 2,265
0 votes
2 answers
378 views

Error when reverse url with multiple arguments - Django

I'm writing a test for an url, problem is it fails when I try to pass multiple arguments, here is some code: #test_urls.py from django.test import SimpleTestCase from django.urls import reverse, ...
Lucas VB's user avatar
0 votes
1 answer
98 views

Why does my Django test pass when it should fail?

I am new to testing of any sorts in coding. This is followup on this answer to my question. Answer establishes that this type of model method should not save object to database: @classmethod def ...
Heikki's user avatar
  • 341
1 vote
1 answer
164 views

test return redirect("account_login") in django use pytest

i using pytest and coverage for testing django project But I don't know how to test the else block that has return redirect("account_login") and fix the red part that says coverage. In your ...
Reza Shakeri's user avatar
1 vote
1 answer
464 views

How to use external files for Django tests

I have to test model validation for checking SVG files. Therefore I want to access to my test files but I've stucked with a error SuspiciousFileOperation. I tried get files from app directory, store ...
volkovik's user avatar

15 30 50 per page
1
2 3 4 5
15