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

Django: How to run tests against empty (non populated) database

By running './manage.py test', data from local 'postgres' database are populated into 'test_postgres' database. I am not able to find way, how to disable this behavior. By running './manage.py test', I want to get non populated database with applied…
0
votes
1 answer

Django: Why does this test fail?

I an new to Django and to Test Driven Devolopment as well. After working through the tutorials in the 1.11 official documentation I am starting my first app: wos_2017_2 This test fails and I cannot figure out why: import unittest from django.test…
0
votes
0 answers

IndexError: list index out of range in Test case

I have strange problems I have next code Using TesCase and APIClient to get request with token class Profile(TestCase): fixtures = ['profiles.json'] def setUp(self): self.client = APIClient() self.user…
0
votes
0 answers

django TestCase is raising NotImplementedError

I have the below test case from rest_framework.test import APIClient from django.test import TestCase from factories import UserFactory class TestUserApi(TestCase): def setUp(self): # Create or get model factory objects …
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
0
votes
1 answer

How to ignore or handle django-hijack from the command line?

I'm writing some unit tests for an existing django project that has had no unit tests to date. When I run the tests from the command line using ./manage.py test I get Traceback (most recent call last): File "./manage.py", line 10, in
Keith John Hutchison
  • 4,955
  • 11
  • 46
  • 64
0
votes
0 answers

How can I use django's default test framework to test a module included in sys.path that is not a subdirectory of the django project?

I have a django (1.8) site that is structured like this: .../django_project/ ./templates/ ./manage.py ./ .../django_app_project/ ./app_name/ ./ ./test_app.py To run the site, I…
lowtex
  • 707
  • 4
  • 22
0
votes
0 answers

test client in tutorial 5 of django

while doing tutorial 5 of django, in the section Django test client every thing work fine until now but when I write this code in shell from "response = client.get(reverse('polls:index'))" I got some error. I am not understanding what the error is…
0
votes
1 answer

Django query created object in tests not working

I have this code in a django test: stockitem_retailer = StockItem.objects.filter(retailer=test_retailer).first() test_subcategory = SubCategory.objects.create(category=test_category, name="outdoors") stockitem_retailer.product.subcategory =…
Alejandro Veintimilla
  • 10,743
  • 23
  • 91
  • 180
0
votes
1 answer

MYSQL django test error: django.db.utils.InternalError: (7, "Error on rename of

I am running a django 1.9.6 app with MYSQL5.7 on IIS 8.5 When i run the python manage.py test command I get the following error message: django.db.utils.InternalError: (7, "Error on rename of '.\test_\#sql-95c_9a.frm' to '.\test_\home_mytable.frm'…
aGurung
  • 71
  • 6
0
votes
0 answers

Django REST framework serialized field containing unexpected characters in test case environment

I am having two model definitions CTA and VariationCTA as follows: class CTA(AbstractTimestampClass): page = models.ForeignKey(Page, related_name='related_page_ctas') css_path =…
0
votes
1 answer

Django 1.7 tests against production DB rather than create test DB

I've been handed a django-1.7 installation and asked to make testing work for an in-house django module. (specifically, we're running Django==1.7.9 and psycopg2==2.5.4) After two days of head scratching, I'm still finding that when I run manage.py…
Adam
  • 366
  • 2
  • 7
0
votes
1 answer

RelatedObjectDoesNotExist

Am working on testing a django model called Authenticator, the Authenticator model has a field with ManyToManyField and OneToOneField. When i test the model i get RelatedObjectDoesNotExist and ValueError: Cannot assign "'matt'":…
uche
  • 85
  • 2
  • 2
  • 14
0
votes
0 answers

running webdriver from vagrant in my local machine

I am running vagrant on windows machine, using "ubuntu/trusty64" box. I running selenium tests on vagrant (using pytest-selenium with django) how can I set the webdriver work with my local machine(windows) firefox/chrome ? did it possible to trigger…
0
votes
1 answer

model_mommy - user to assignment relationship

I'm finally setting up testing for my Django app, but I'm having difficulties getting started. I'm using model_mommy to create dynamic data for my tests, but have the following problem: The view I'm testing is supposed to show me all the assignments…
LukasKawerau
  • 1,071
  • 2
  • 23
  • 42
0
votes
1 answer

Importing test scripts into a django testrunner

I have a test runner in a django package that is split across two directories, like…
user764357