django-tests Questions

4

Solved

I have the following validation function in my model: @classmethod def validate_kind(cls, kind): if kind == 'test': raise ValidationError("Invalid question kind") which I am trying to test as ...
Hysterectomize asked 21/4, 2018 at 10:43

2

I'm trying to test some simple abstract mixins using django 2.2.4/sqlite3 2.6.0/python 3.6.8. Currently I'm having issues deleting a model from the test database using the schema editor. I have t...
Palmer asked 21/8, 2019 at 3:13

4

I'm trying to run test cases, but I get below error. Run command : python manage.py test Type 'yes' if you would like to try deleting the test database 'test_project_management_db', or 'no' to canc...
Hayman asked 10/1, 2018 at 9:37

2

Solved

how is possible to add 'Authorization': 'Token' to TEST request in Django/DRF? If i use simple requests.get(url, headers={'Authorization': 'Token'} all work perfect but how to do such request in T...
Jumper asked 16/11, 2017 at 14:8

2

Solved

I have django application with 5 legacy databases. Almost all models are set with the meta attribute managed=False. Since managed=False is set, migrations for each model have been created with the ...
Hawes asked 2/5, 2016 at 15:41

1

Solved

I have a view function similar to def my_function(request): session = create_something('some_random_string') return redirect(session.url, code=303) To test it import unittest from django.test im...
Illegitimacy asked 14/11, 2022 at 18:23

4

I am using RequestFactory in a Django test, and I can't find the right way to access the session variable, and I'm getting the following error when I try self.factory._session["zip_id"] or self.fa...
Peccable asked 9/10, 2016 at 18:52

2

Solved

I've been really enjoying the convenience of setUpTestData and --keepdb in Django 1.8! However, I am running into an issue keeping data consistent across multiple test files. I'd like to have my s...
Lithology asked 9/7, 2015 at 18:41

3

How can I use a pytest fixture within a TestCase method? Several answers to similar questions seem to imply that my example should work: import pytest from django.test import TestCase from myapp.m...
Appendectomy asked 25/10, 2020 at 21:24

3

This is my testing function for views.py which I have mention below: def test_operation_page(self): url = reverse('operation') response = self.client.get(url) self.assertEqual(response.status_...
Imaginative asked 12/7, 2019 at 12:27

2

Solved

How to define a field that depends on other field using factory-boy? For instance, I'd like to define an email that depends on the first name and last name of an User. I tried using the post_gen...
Puttyroot asked 27/11, 2015 at 23:2

3

Solved

I'm using python 3.5 and Django 1.10 and trying to test my app in tests.py, but an error appeared, it said: ValueError: Cannot assign "1": "NewsLetter.UserID" must be a "User" instance. so how to t...
Brittan asked 17/6, 2017 at 12:31

1

I am trying to write tests for an app to check that a group has the required permission for a particular model or not in django. App Name:- Blog Model Name:- Post I am able to query all the permiss...
Lungki asked 5/12, 2020 at 11:2

4

Solved

I am trying to use bulk update from drf-extensions. To make it work, there is a safeguard requiring the header "X-BULK-OPERATION": 'true'. I can get the application working using curl or my angular...
Furious asked 30/10, 2018 at 22:28

1

Solved

I'm trying to Test non-login user redirect to login url. Is there a way to pass get parameter (example 'next') to reverse_lazy? I'm using class-based views. class SecretIndexViewTest(TestCase): ur...
Damson asked 3/3, 2021 at 2:27

3

Solved

I'm trying to write some tests for my django app and it's throwing up an error: File "/Users/croberts/.virtualenvs/litem/lib/python3.4/site-packages/django/contrib/auth/__init__.py", line 101, in ...
Peridotite asked 26/2, 2016 at 19:2

2

Solved

I am getting this error when running pytest. I am following this tutorial: https://channels.readthedocs.io/en/latest/topics/testing.html django.core.exceptions.ImproperlyConfigured: Requested sett...
Metaphysics asked 15/3, 2019 at 4:46

3

Solved

Maybe I misunderstand the purpose of Django's update_or_create Model method. Here is my Model: from django.db import models import datetime from vc.models import Cluster class Vmt(models.Model):...
Studio asked 18/6, 2018 at 19:1

3

Solved

I am working on a django project in which I have multiple apps. Every app has a tests directory which has test for whole project. My directory structure is as follow. Project App_1 tests __init...
Everett asked 11/4, 2016 at 10:30

2

Solved

I have written some test cases for my project when I run these test cases, it creates test database for alias 'default' every time, after giving message then destroy database. I am concern only wit...
Metopic asked 18/9, 2015 at 5:0

1

I am trying to change my request.data dict to remove some additional field. It is working completely fine in views. But when I run test cases for the same, I get this error: AttributeError: This Q...
Pichardo asked 17/4, 2020 at 17:38

1

I use Django ORM inside async code. Everything works fine and all tests pass. However, DB connections do not close properly after tests. Here is an example: from asgiref.sync import sync_to_async,...
Protege asked 15/2, 2020 at 19:33

6

Solved

I have the following test.py file in django. can you please explain this code? from contacts.models import Contact ... class ContactTests(TestCase): """Contact model tests.""" def test_str(self...
Licensee asked 29/7, 2013 at 9:38

1

Solved

So I've got a django project with several applications. Each application use its own database, and they share a common database containing django tables (such as auth, sessions). For this I've g...
Apulia asked 5/7, 2019 at 8:31

1

Solved

I am learning django test and i found django factory boy library very helpfull for writing testcase but one thing i am not getting.. forexample my one of Factory name is BlogFactory so i notice, ...
Swordbill asked 22/6, 2019 at 16:9

© 2022 - 2024 — McMap. All rights reserved.