Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
0 votes
0 answers
30 views

Sometimes, I have many flaky test failures due to one error: ImportError: cannot import name 'task_import_events_to_db' from 'app.tasks' (unknown location) It seems the tests fail because of this ...
Vasyl Bilych's user avatar
0 votes
1 answer
40 views

I’m working on writing unit tests for a DRF project using pytest and factory_boy. I’m running into issues with many-to-many relationships. Specifically, when I try to use .build() in my unit tests, ...
Pierce's user avatar
  • 1
1 vote
1 answer
62 views

I have a Model class with a series of constraints that I am attempting to test, and I am unable to get these constraints to return an IntegrityError in testing. The class is as follows: from django.db ...
dabo_tusev's user avatar
0 votes
0 answers
57 views

I am working on a tutorial project. The same code works for the instructor but doesn't work for me. I have a file for custom commands: import time from psycopg2 import OperationalError as ...
The Bat's user avatar
  • 1,113
0 votes
1 answer
80 views

I am a university student, and I decided to use Django for my final year project. This means I am limited to using the University's MySQL database server. On the server, I am only allowed to have one ...
fiocotti's user avatar
0 votes
1 answer
54 views

i have this problem when i run my testcase with django and mysql. when i run manage.py test i've got this error. Found 1 test(s). Creating test database for alias 'default'... System check identified ...
Francesca Fabozzi's user avatar
0 votes
0 answers
17 views

I've been trying to run some functional tests (LiveServerTestCase) with Selenium for a Django app. For demonstration it's a note taking app. When I'm trying to simulate note creation, it requires ...
Andre de Jesus's user avatar
0 votes
3 answers
63 views

I know this questions has already been asked, but none of the answers works for me. Whenever I try to use the client login in Django tests, it basically gets ignored and I get a redirect to the login ...
danilociaffi's user avatar
2 votes
2 answers
485 views

I have a simple django project that I'm making in pycharm. The directory structure is the following: zelda_botw_cooking_simulator |-- cooking_simulator_project |---- manage.py |---- ...
BLimitless's user avatar
  • 2,765
0 votes
0 answers
43 views

I'm trying to avoid code duplication so I want to import login from users/test to the ordering/test where I need to test different views that have @login_required. users/test.py User = get_user_model()...
M4rc0txt's user avatar
-2 votes
1 answer
135 views

I am currently writing tests using Django’s unit tests (based on Python standard library module: unittest). I have written this test for my Contact model which passes: class ContactTestCase(TestCase): ...
Uchenna Adubasim's user avatar
1 vote
1 answer
41 views

I am trying to pass request to a Django form in unittest. This is my test: def test_AddPairedStudyForm(self): self.client.force_login(self.user) request = RequestFactory().get(reverse("...
HenryM's user avatar
  • 5,801
0 votes
1 answer
58 views

I want a test database created for my default database in Django latest version, for that I configured in project settings.py file as below. DATABASES = { 'default': { 'ENGINE': 'django.db....
Kapil Yadav's user avatar
0 votes
1 answer
37 views

I am trying to create test cases which only differ by which user is logged in. Therefore I figured defining the tests in a base class and creating sub classes which log in the user during setUp() ...
kisa's user avatar
  • 53
1 vote
1 answer
56 views

This makes a Django test using the test client run very much faster, where login security is not an important part of the test from django.test import TestCase, Client, override_settings @...
nigel222's user avatar
  • 8,312
2 votes
0 answers
423 views

I use the django-silk to profile the APIs of my Django project (Django + DRF). Currently, I call APIs in the browser (using DRF browsable API) and then I can see the API profiling data in the silk. ...
msln's user avatar
  • 1,563
2 votes
2 answers
204 views

The following simple test, from django.test import TestCase class TestSetup(TestCase): def test_setUp(self): pdb.set_trace() # Code here deleted, it made no ...
Ron's user avatar
  • 255
0 votes
0 answers
34 views

I'm encountering an AssertionError in my Django unit test when attempting to save a POST request to an existing list. Despite creating the list and sending the POST request successfully, the test ...
Zimzozaur's user avatar
0 votes
1 answer
67 views

I am learning basics of Django following official tutorial and adding some new features to my application. So I added a view that can nullify all votes of particular question def nullask(request, ...
MrAdvocat2019's user avatar
1 vote
1 answer
288 views

I'm developing Django application and wrote a test that checks if view method acts correctly. I need to send some data in request, including the image file. In my case: def setUp(self): ... self....
InOutLake's user avatar
0 votes
2 answers
115 views

In django, I am trying to run tests on a test db, but I can't seem to get the test db stood up properly... I have 226 models on my real db, but when I run python manage.py test (test location) it ...
Matt S's user avatar
  • 43
3 votes
1 answer
221 views

I'm trying to run Django tests but I'm encountering with this error - django.template.exceptions.TemplateSyntaxError: 'socialaccount' is not a registered tag library., but normally it have to work ...
party's user avatar
  • 99
0 votes
2 answers
150 views

I'm starting to write tests for my endpoint, "categories/", and I can't get past a custom permission that I have added to the view that is being tested. In this permission, it checks the ...
JDiamond's user avatar
0 votes
1 answer
110 views

I'd like to test files produced on the admin website by import_export.admin.ExportActionMixin in Django. In particular I'd like to test the admin command by looking into the file (which I download on ...
NSS's user avatar
  • 37
0 votes
1 answer
449 views

When running tests with coverage using PyCharm on django (python) project, im having the following error: Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm 2023.1.2\...
Jorge Miguel Soares Lopes's user avatar
1 vote
1 answer
122 views

I have django function, that takes JSON-data from request, validates it and save to db. I want to test this func, but POST request doesn’t work, error ‘json.decoder.JSONDecodeError: Expecting value: ...
Андрей's user avatar
1 vote
0 answers
619 views

I have some Selenium-based integration tests (subclassed under django.contrib.staticfiles.testing.StaticLiveServerTestCase) for my Django app that require a functioning user-uploaded media ...
mgalgs's user avatar
  • 17k
0 votes
1 answer
101 views

I want the following test to pass, but I am always getting a 404 Error. But I would expect the "get all" request to return all users. import json from django.test.utils import ...
KIC's user avatar
  • 6,069
1 vote
0 answers
331 views

I have weird behavior of Django tests in parallel mode: Command to run tests: python manage.py test --parallel Sometimes it works fine but in random moments I got error during cloning DB. Cloning test ...
Y S's user avatar
  • 11
0 votes
1 answer
50 views

I have an issue, some data are missing in my serializer (in validate and create functions). My Model: class PostsImage(models.Model): image = models.ImageField(upload_to="posts/images") ...
darkvodka's user avatar
  • 333
0 votes
1 answer
1k views

I use postgres as DB for my project. I would like to make and run some test in my test.py file with sqlite DB. I change my settings.py file to do that with sqlite3 db, but when I try to run my simple ...
Mike's user avatar
  • 429
2 votes
2 answers
1k views

I am writing automated tests in Django and started writing tests for an API endpoint that supports the put method. I am making my put request like so: response = self.client.put(path, data=json.dumps({...
Amir Kooshky's user avatar
0 votes
0 answers
292 views

I have the following piece of Python code and I would like to write tests for this function: def http_request(method, url) session = requests.Session() retries = Retry(total=3, backoff_factor=...
iAmoric's user avatar
  • 2,005
1 vote
1 answer
32 views

I'm writing tests for locallibrary app following the tutorial on MDN. Both classes that test views share similar login code, but it only works in one class I tried finding spelling errors and comping ...
rad2's user avatar
  • 11
1 vote
1 answer
158 views

I'm curious how django runs test parallelly with python manage.py test --parallel. Would someone please explain the what happens under the hood and and the the life cycle of test with an example.
Abhinav Prakash's user avatar
1 vote
1 answer
483 views

I need to add a custom header to the APIClient for a test. I have tried to follow this section of the official docs from rest_framework.test import APIClient client = APIClient() client.credentials(...
import_sarcasm's user avatar
1 vote
1 answer
703 views

in a github action yml file it's defined this step to run django tests: python manage.py test --failfast --parallel 2 looks like --parallel 2 breaks it: multiprocessing.pool.RemoteTraceback: "&...
Luke's user avatar
  • 1,844
0 votes
1 answer
235 views

I have test.py from rest_framework.test import APITestCase from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse class PostImageTest(APITestCase): def ...
Srivatsa's user avatar
  • 106
1 vote
2 answers
146 views

I am testing whether my blog posts are in reverse chronological order. To do so, I must set random dates for each post created. I'm using faker to set the dates. I am getting back a fake date, but it'...
user3605767's user avatar
0 votes
1 answer
55 views

models.py class Major(models.Model): major = models.CharField(max_length=50, unique=True) description = models.TextField() image = models.ImageField(default='default_pics/default_major.jpg'...
Dylan Bergmann's user avatar
1 vote
1 answer
621 views

I'm trying to run a test for my view and I get this error: Django: django.urls.exceptions.NoReverseMatch: Reverse for 'create' not found. 'create' is not a valid view function or pattern name. Here is ...
SReza S's user avatar
  • 301
1 vote
0 answers
148 views

I'm trying to implement factory boy and wagtail factories to generate tests for the blog section of my site, at /blog/, which uses Wagtail CMS. However, I'm getting a 404 error when doing self....
user3605767's user avatar
0 votes
1 answer
129 views

I have a Django project for which I have tests (nothing special). The thing is I'd like to have colored results when running tests and I don't know how to do that. On a daily basis, I run tests from ...
lbris's user avatar
  • 1,259
1 vote
3 answers
819 views

I am writing tests for class-based views in the django project I am writing as part of a course. Currently, I am stuck trying trying to test a view that directs to an edit page that requires a user to ...
ClubShrimp's user avatar
0 votes
2 answers
252 views

The view has IsAdminUser restriction. I am also using token authentication. This is the view: class UserRegister(generics.CreateAPIView): permission_classes = [IsAdminUser] queryset = User....
Arbi Kullakshi's user avatar
0 votes
1 answer
441 views

For context, when one wants to change settings in a test (yes, it's ok to change it there), we can use override_settings() or modify_settings() (as observed here). That works when running the tests in ...
Tiago Peres's user avatar
  • 15.9k
1 vote
1 answer
401 views

I am building a test case for an endpoint. Visiting the endpoint in the local development using the browser works fine -- I get the expected response. However, during the test, I get an ...
Nikko's user avatar
  • 1,572
0 votes
1 answer
218 views

I use django-minio-backend in order to integrate Django and Minio. I want to create a test bucket for created media files during tests running. I tried to do that in a custom test runner as follows: ...
msln's user avatar
  • 1,563
0 votes
1 answer
69 views

I have a LoginSerializer that has the block of code as below def validate(self, attrs): username = attrs.get('username', '') password = attrs.get('password', '') user = auth.authenticate(...
Isaac Hatilima's user avatar
3 votes
2 answers
746 views

I have a tests in my Django app. They're working well, but i want to disable showing console logging like .Bad Request: /api/v1/users/register/ One of my tests code def ...
NelttjeN's user avatar
  • 100

1
2 3 4 5
25