Questions tagged [django-tests]

Use for questions about testing applications based upon the Python web framework Django, or the features provided in the module itself (django.test)

docs: https://docs.djangoproject.com/en/2.1/topics/testing/overview/

450 questions
0
votes
1 answer

Calling database table from tests.py

I have the following in my tests.py class TestSugar(TestCase): def test_empty_sugar_applicants(self): Sugar_Applicant.objects.using('sugarcrm').all().delete(); number_of_sugar_applicants =…
Jon
  • 3,174
  • 11
  • 39
  • 57
0
votes
2 answers

Django 1.7.1 custom field failing when running tests

I have just upgraded my Django 1.6.5 project to Django 1.7.1. I followed the steps documented to move from South to Django 1.7.1 and it works perfectly. The issue I have is when I run "python manage.py test" on my project, it fails with the…
LondonAppDev
  • 8,501
  • 8
  • 60
  • 87
0
votes
1 answer

Django test client get row id from query

How can i print the id from the response in the below code.The user does exist in the DB.Also i come across this error. from django.test import Client c = Client(enforce_csrf_checks=False) response = c.post('/reg/_user/', {'firstname': 'test',…
Rajeev
  • 44,985
  • 76
  • 186
  • 285
0
votes
1 answer

Perform tests on Django using multiple DBs (MySQL and MongoDB)

I am trying to run tests on the app I am developing and I am having problems. The application uses 2 databases, an MySQL one for configuration and relational data and a MongoDB one for some other records that are not relational. It works when I'm…
Fabiot
  • 429
  • 1
  • 4
  • 13
0
votes
1 answer

Django Test - How to run tests with different settings file for a specific app?

I have a project and into this project I have different apps.. The problem is, a specific app is another website inside the same project and uses different settings file. When I run the tests separated, it works perfectly, when I try to run all…
Lara
  • 2,170
  • 6
  • 22
  • 43
0
votes
1 answer

Debug django tests

I see that TestCase has a method Debug(), but I can't find any example on how to implement it. As far as I've tried, nothing works. Can anyone provide some code as to how to use it?
Ben
  • 6,986
  • 6
  • 44
  • 71
0
votes
1 answer

Testing customized django user class

My goal: when a user is saved, set the username to the email address Test class userAccount/tests.py: #----------------------------------------------------------------------# # Test that the User is saved correctly…
Ben
  • 6,986
  • 6
  • 44
  • 71
0
votes
1 answer

Inside Django tests folder not able to import outer modules

I am trying to create a tests folder in my django app. My app has following structure: myapp myapp/tests/__init__ mtapp/tests/test_email myapp/function Now i am trying to import function inside test_email file. and executing test case as python…
Jayendra Gothi
  • 682
  • 2
  • 11
  • 26
0
votes
2 answers

django 1.6 unit test error TemplateSyntaxError: block tag with name 'content' appears more than once

I'm getting a strange error from the Django tests, I get this error when I test Django or when I unit test my story app. It's complaining about multiple block tags with the name "content" but I've renamed all the tags so there should be zero block…
0
votes
2 answers

Initializing MEDIA_ROOT and the Django Storage before each test

As explained in this question, I'm trying to isolate file-system changes done in Django tests. I'm basically changing settings.MEDIA_ROOT before the tests are run. Unfortunately, the Django storage class seems to be unaffected by it, so files are…
zmbq
  • 38,013
  • 14
  • 101
  • 171
0
votes
1 answer

Running Django Tests with RequestFactory is returning __init__.py errors

I'm not sure what I'm doing wrong. I'm trying to follow this example: https://docs.djangoproject.com/en/1.6/topics/testing/advanced/#module-django.test.client I've created my test and the return is odd. tests.py: from django.contrib.auth.models…
Dave Merwin
  • 1,382
  • 2
  • 22
  • 44
0
votes
1 answer

django testrunner not running my tests

I've got the following tests.py file: from django.test import TestCase from lxml import etree import tempfile import utils class CreateSurveyFromCsvTextTests(TestCase): def parsesSurveyPassedInAsCsvAndReturnsXmlRepresentation(self): …
Nicolas Straub
  • 3,381
  • 6
  • 21
  • 42
0
votes
1 answer

How to write a Test in django

I have given my view and models below and i need to write testcase for the following This is my view: def dashboard_vendors(request, template="template/vendors.html"): """ Listing all the vendors """ try: page =…
user2842009
0
votes
1 answer

Upgrading from Django 1.3 to 1.5.5 app unit test failing with AttributeError: PositionForm object has no attribute 'cleaned_data

I am upgrading from Django 1.3 to 1.5.5. All the tests worked before but now this one is failing and I cant figure out why. I have included the stack trace and functions that appear in the stack trace. There are a lot of log statements for…
Alex
  • 1,891
  • 3
  • 23
  • 39
0
votes
2 answers

App tables not created when running test

When i run my app test django don't create my app tables and throw an error. My test file: from django.test import TestCase class MyTest(TestCase): fixtures = ['initial_data.json'] def test_my_stuff(self): [...] When i run…
bux
  • 7,087
  • 11
  • 45
  • 86
1 2 3
29
30