django-testing

(DatabaseError: no such table: django_session) ERROR during Django 1.3 selenium testing

萝らか妹 提交于 2019-12-23 23:14:57
问题 I'm trying to use django selenium for testing my django1.3 application. The database backend for the testing is sqlite3. Here is a snippet of my settings file. if 'test' in sys.argv: DB_ENGINE = 'django.db.backends.sqlite3' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'TEST_NAME': ':memory:', 'NAME': 'database_one', }, 'database_two': { 'ENGINE': 'django.db.backends.sqlite3', ] 'TEST_NAME': ':memory:', 'NAME': 'database_two', }, 'database_three': { 'ENGINE': 'django.db

Django 1.5.1 'ImportError: No module named urls' when running tests

爱⌒轻易说出口 提交于 2019-12-23 18:04:31
问题 I've started project with Django 1.5 I've the following urls, views, and tests of the profile app. When I browse localhost:8000/profiles it works just fine but when I run test for profile app ./manage.py test profile it fails with the following exception File "<stdlib>/site-packages/django/core/urlresolvers.py", line 342, in RegexURLResolver.urlconf_module self = <RegexURLResolver 'yoda.urls' (None:None) ^/> 340 return self._urlconf_module 341 except AttributeError: --> 342 self._urlconf

django object ids increment between unit tests

丶灬走出姿态 提交于 2019-12-23 10:15:08
问题 I'm using Django 1.2.3-3+squeeze1 on Debian squeeze with PostgreSQL 8.4.7-0squeeze2 (though I don't think PostgreSQL is relevant here), and running Django unit tests based on unittest with the following setUp and tearDown def setUp(self): print "running setup" self.c = Client() self.user = User.objects.create_user('faheem', 'faheem@email.unc.edu', 'foo') self.logged_in = self.c.login(username='faheem', password='foo') settings.MEDIA_ROOT='/tmp/' #settings.ZIP_UPLOAD='/var/tmp/zip/' def

Getting rid of empty models.py in django testsuite

£可爱£侵袭症+ 提交于 2019-12-23 07:44:08
问题 I have two pure service apps, that act as servant to my core models. Hence, they do not have any own models. While the testsuite for the first service runs fine, the second throws the following error: django.core.exceptions.ImproperlyConfigured: App with label location is missing a models.py module. If I add an empty models.py, the suite runs fine. I can't spot a difference in terms of architecture / structure between the apps. But I want to get rid of the empty, unneeded models.py. How would

Unit tests fail to load with Django in Visual Studio

余生颓废 提交于 2019-12-23 03:18:18
问题 I am using Django 1.10.5 with Visual Studio 2015. My project is running in a virtual environment. I am following the beginner tutorial here. The project runs fine, but when I try to run unit tests from the Visual Studio "Test Explorer" they fail with to error: "django.core.exceptions.AppRegistryNotReady: App aren't loaded yet." This is my test class: import datetime from django.test import TestCase from django.utils import timezone from .models import Question class QuestionTestCase(TestCase)

Django test tables are not being created

走远了吗. 提交于 2019-12-22 23:21:40
问题 I'm trying to write test cases for my django project but when I run "$ ./manage.py test" command its creating test database but its not creating any tables and I'm getting an error that table does't exists. Any suggestions are welcome. Here is my model which i have created through "./manage.py inspectdb > models.py" class MyCustomModel(models.Model): name = models.CharField(max_length=200) last_name = models.CharField(max_length=200) class Meta: managed = False db_table = 'MY_TABLE' 回答1: Your

How to test a Django form with a ModelChoiceField using test client and post method

六眼飞鱼酱① 提交于 2019-12-22 18:29:20
问题 How do I use Django test client.post to test a form that has a ModelChoiceField? How should the data dictionary passed to the post method be written? The way I am doing does not select any value at all. I have a form with the following field: country = forms.ModelChoiceField( label="País", queryset=Country.objects.all().order_by('name'), required=True, widget=forms.Select(attrs={ 'onchange': "Dajaxice.party.update_country(Dajax.process, {'option':this.value})" }, ) I also have the following

How to test a Django form with a ModelChoiceField using test client and post method

心已入冬 提交于 2019-12-22 18:29:06
问题 How do I use Django test client.post to test a form that has a ModelChoiceField? How should the data dictionary passed to the post method be written? The way I am doing does not select any value at all. I have a form with the following field: country = forms.ModelChoiceField( label="País", queryset=Country.objects.all().order_by('name'), required=True, widget=forms.Select(attrs={ 'onchange': "Dajaxice.party.update_country(Dajax.process, {'option':this.value})" }, ) I also have the following

how do I efficiently test this Django model?

北城以北 提交于 2019-12-22 13:53:27
问题 I'm building an authentication system for a website, I don't have prior test experience with Django. I have written some basic tests. the model, class User(AbstractBaseUser, PermissionsMixin): username = models.CharField(max_length=25, unique=True, error_messages={ 'unique': 'The username is taken' }) first_name = models.CharField(max_length=60, blank=True, null=True) last_name = models.CharField(max_length=60, blank=True, null=True) email = models.EmailField(unique=True, db_index=True, error

How should I test a database-driven Django CMS for 404 errors?

廉价感情. 提交于 2019-12-22 08:54:50
问题 I have designed a basic content management system in Django that uses the database to track Article objects, then displays these Article objects on my website. Each Article uses template tags that I frequently update. Occasionally, I will accidentally break one or more articles on my site when I update a template tag. For example, if I change the required arguments for a template tag referenced by a given article, and forget to update the template tag code within that article, the article