458 questions
0 votes
0 answers
57 views
Getting attribute error in Django BaseCommand- Check
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 ...
2 votes
1 answer
47 views
How to use multiple database connections in Django TestCase
I'm writing a testcase to reproduce deadlock in my service. After I use multiprocessing to create a two thread, I found they use the same database connection. So I can't reproduce the deadlock ...
0 votes
0 answers
73 views
Register page not redirecting to the homeowner-dashboard when clicking on 'register' button
The register page is not redirecting to the homeowner-dashboard page when I click on the register button. When clicking on it, literally nothing happens. I inspected the Console and all it shows is ...
0 votes
1 answer
88 views
Django Testing: Use main database as only one database available?
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 ...
2 votes
2 answers
504 views
Configuring Django Testing in PyCharm
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 |---- ...
1 vote
1 answer
66 views
Elegant way to add a list view test case in drf
I have one concern in writing the test code for list view. For DRF's list view, it responds to multiple data. What should I do if I assume that the response.data object is a model with many fields? ...
0 votes
0 answers
44 views
Importing login of users/tests module to another application/tests not working in Django
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()...
1 vote
1 answer
42 views
How do I pass request to a form in test
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("...
0 votes
1 answer
63 views
In python Django how to define test database and keep records inserted in test database until cleaned in tearDown method of testcase
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....
1 vote
1 answer
23 views
How to use assertEqual(resolve()) for class-based view?
I'm trying to test BookList url but got this error " self.assertEqual(resolve(url).func, BookList.name) AssertionError: <function View.as_view..view at 0x0000025699398360> != 'BookList'&...
0 votes
1 answer
142 views
Django test a custom field in a test model using SqlLite3; cannot disable constraint checking to create database table
I need to write test for a custom field with access to the database. The code is the following : class TestMyField (TestCase): def SetUpClass(cls): super().setUpClass() class MyModel(...
0 votes
0 answers
23 views
Django Unit Test Fail when i test UpdateView
In my project i have UserUpdateView like this: class UserUpdateView(AuthenticationMixin, AuthorizationMixin, SuccessMessageMixin, UpdateView): '''Update User info(username, full/second name, password)...
2 votes
2 answers
204 views
Django test suite throws error on field that doesn't exist in latest migrations
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 ...
0 votes
1 answer
33 views
How do I make my test behave as expected when my model is updated?
My view class MovieUpdateView(UpdateView): model = Movie template_name = "movie_update.html" fields = [ 'movie_name', 'movie_year', 'movie_director', ...
0 votes
0 answers
37 views
AssertionError in Django Unit Test: Unable to Retrieve Correct Count from Database
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 ...