django-unittest

Django Unit Test – IDs of created objects

Django Unit Test – IDs of created objects Question: Sample models.py models.py class Food(models.Model): name = models.CharField(max_length=50, verbose_name=’Food’) def __str__(self): return self.name Suppose that I have written unit test/s: from django.test import TestCase from myapp.models import Food class TestWhateverFunctions(TestCase): “”” This class contains tests for whatever functions. “”” def setUp(self): “”” This method runs before …

Total answers: 3

Django Unitest: Table doesn't exist

Django Unitest: Table doesn't exist Question: I created a simple test case like this: from unittest import TestCase import user_manager class UserTest(TestCase): def test_register(self): email = “[email protected]” password = “123456” result, user = user_manager.setup_new_user(email, password) self.assertEqual(result, CodeID.SUCCESS) Then I run the testcase: python manage.py test users And here is the log: Creating test database for …

Total answers: 2

Django Unit Testing taking a very long time to create test database

Django Unit Testing taking a very long time to create test database Question: For some time now, my unit testing has been taking a longer than expected time. I have tried to debug it a couple of times without much success, as the delays are before my tests even begin to run. This has affected …

Total answers: 5

How to see which tests were run during Django's manage.py test command

How to see which tests were run during Django's manage.py test command Question: After tests execution is finished using Django’s manage.py test command only number of passed tests is printed to the console. (virtualenv) G:Project>python manage.py test Creating test database for alias ‘default’… True .. ———————————————————————- Ran 2 tests in 0.017s OK Destroying test database …

Total answers: 2

Running django tutorial tests fail – No module named polls.tests

Running django tutorial tests fail – No module named polls.tests Question: I’m playing with django 1.6 tutorial but i can’t run tests. My project (name mydjango) and app structure (name is polls) are as shown below in a virtualenv. (.nja files are just created by ninja-ide the ide I’m using) . ├── __init__.py ├── manage.py …

Total answers: 4

What is the clean way to unittest FileField in django?

What is the clean way to unittest FileField in django? Question: I have a model with a FileField. I want to unittest it. django test framework has great ways to manage database and emails. Is there something similar for FileFields? How can I make sure that the unittests are not going to pollute the real …

Total answers: 6