Questions tagged [django-unittest]

django-unittest tag refers to writing unit tests in Django, tests that are expressed as methods on a Python class that subclasses unittest.TestCase or Django's customized TestCase.

django-unittest tag refers to writing unit tests in Django, tests that are expressed as methods on a Python class that subclasses unittest.TestCase or Django’s customized TestCase.

329 questions
0
votes
0 answers

Django unable to save FloatField value to 0.0

I have a method on a model that updates a value to 0.0 and calls save(). Problem is save() is never saving the value if it is 0. Here is the code: class Item(models.Model): stock_quantity = models.FloatField( null=True, blank=True,…
0
votes
1 answer

How to modify all databases when overriding DiscoverRunner setup_databases with parallel

I'm running the tests with --parallel and want to add some object to every database that is created (for each process). currently, I have a CustomTestRunner which inherit from DiscoverRunner. In that class, I'm overriding setup_databases…
Asaf
  • 3
  • 1
0
votes
1 answer

ModuleNotFoundError: No module named 'jiraglean.jiraglean'; 'jiraglean'

I am trying to run a tests file in a Django project, the app is called jira and project jiraglean , test file is tests.py I run the test with: jiraglean test jira.tests --settings=core.settings.test Which causes this error: File…
godhar
  • 1,128
  • 1
  • 14
  • 34
0
votes
1 answer

testing in Django

I am trying to test my Django application to get 100 % statement coverage. I Am using class-based view and overwriting some af the functionalities. One of them is the form valid in my AttendanceLogFormView in my views.py My question is how do I test…
Nadia Hansen
  • 697
  • 2
  • 6
  • 16
0
votes
1 answer

Best approach to load specific urls (views) in Django project

I have a Django app that exposes the following views: A,B,C...Z. This app is deployed on MACHINE-1. There was a new business requirement to deploy on MACHINE-2 the same Django app but with a subset of those views, let's say A,B, C. My simple…
0
votes
1 answer

Django - Unit test object's delection does not work as expacted

For 2 of my models, Users and Groups, I have a view to delete objects. The code is almost the same for each of them, it works in the application but unit test have different results: it works for users, not for groups. Thanks in advance for your…
0
votes
1 answer

Django Unit Test Assertion Error for Serialization

I am trying to perform the unit test for a feature in my website, whereby the user uploads a JSON file and I test if the JSON file is valid using serialization and JSON schema. When running the following test code I keep getting assertion…
0
votes
1 answer

Unittest with mock for django login

I am writing Unittests for the Login on Django. And I have serious problems with the get_user(). I just can't figure out how to get through this function in test. I can't make a mock, and I can't substitute values. I think I'm wrong do it. But I…
Elliot13
  • 368
  • 2
  • 4
  • 16
0
votes
2 answers

Django Unit Test - filtered query results

I am relatively new to Django and very new to writing unit tests. I'd like to ask for assistance but I'm a bit stuck with where to even begin. The app I'm working with allows a teacher to assign multiple assignments to a student. On the student…
0
votes
0 answers

Managing migration of large number of fixtures in Django for unit testing

I currently have one fixture for all my tests for my Django application. It is fine however updating units tests each time I add a new object to my fixture is tedious. Objects count and equality of query set have to be updated. Many "get" methods…
Jean Bouvattier
  • 303
  • 3
  • 19
0
votes
0 answers

My unittests don't work due to connection already closed

I am trying to do unittests but it does not work. Here is my file of tests : class SimpleTest(TestCase): def authenticate(self): useremail = 'myemail@email.fr' userpassword = 'password' c = self.client loggedin =…
Adam
  • 9
  • 2
0
votes
0 answers

Can not send image with data to serializer

I'm trying to send some data and an image and put them into their own models. I can see the data that comes to the view if I print it:
0
votes
1 answer

unittest\loader.py raise ImproperlyConfigured

The following code causes problems, If I add in my unit test file in Django : from myApp.models import anyModel Failed to import test module: test_App.test_models Traceback (most recent call last): File "C:\Program Files…
0
votes
1 answer

How can I skip authentication in a Django APIRequestFactory call?

So essentially I want to make a request to a ViewSet without requiring to authenticate, does Django APIRequestFactory make this possible? This works: from django.test import TestCase from .views.SomeViewSet from rest_framework.test import…
0
votes
1 answer

The login session is not alive after setup in django unitest

I have the following issue. I'm following some tutorials to get some understanding of Django and I want to do now a test of a view: view.py: class OwnerListView(LoginRequiredMixin, generic.ListView): model = Owner paginate_by = 10 …
nck
  • 1,673
  • 16
  • 40