django-testing Questions

4

Solved

I have the following validation function in my model: @classmethod def validate_kind(cls, kind): if kind == 'test': raise ValidationError("Invalid question kind") which I am trying to test as ...
Hysterectomize asked 21/4, 2018 at 10:43

12

Solved

One of my django application unit test fails with DatabaseError: ORA-00942: table or view does not exist I would like to see actual SQL query that caused this error. Do you know how to achieve t...
Rosaliarosalie asked 31/10, 2012 at 16:42

3

I'm using Django 1.6 with Python 3.3 on Ubuntu 13.10 and Postgres. I have a model User defined as follows: from django.db import models from django.contrib.auth.models import AbstractUser from c...
Neuritis asked 4/12, 2013 at 23:29

16

Solved

When I try to test any app with command (I noticed it when I tried to deploy myproject using fabric, which uses this command): python manage.py test appname I get this error: Creating test data...
Zimmer asked 6/1, 2013 at 19:51

3

Solved

When I run tests in parallel, I get random failures because one test interferes with the cache of another test. I can work around the problem with @override_settings( CACHES={ "default"...
Spastic asked 23/3, 2022 at 8:6

7

im having an issue with a tutorial im following. we have gotten to the point of testing and i continue to get an error when running python manage.py test Here is my error: (restapi) chrismalte...
Underprivileged asked 3/8, 2018 at 16:10

6

Is it possible to pass command line arguments to Django's manage.py script, specifically for unit tests? i.e. if I do something like manage.py test myapp -a do_this Can I receive the value do_th...
Hermilahermina asked 30/1, 2015 at 5:39

4

Solved

I'm having a problem very similar to Django's Querydict bizarre behavior: bunches POST dictionary into a single key and Unit testing Django JSON View. However, none of the questions/responses i...
Cathryncathy asked 17/6, 2012 at 6:25

2

Solved

I am testing a class based view using mock to raise an exception. On exception, a message should be created and then a redirect executed. Whilst I am able to test that the redirect has been execute...
Reseat asked 25/11, 2022 at 14:42

4

Solved

During invoking pytest from the shell I get the following output, because my test is stored in apps.business.metrics.tools.tests.py, and during import of the module apps/business/metrics/widgets/em...
Millen asked 13/2, 2019 at 1:21

8

Solved

I'm writing a reusable django app and I need to ensure that its models are only sync'ed when the app is in test mode. I've tried to use a custom DjangoTestRunner, but I found no examples of h...
Sewell asked 5/8, 2011 at 13:24

2

Solved

I have django application with 5 legacy databases. Almost all models are set with the meta attribute managed=False. Since managed=False is set, migrations for each model have been created with the ...
Hawes asked 2/5, 2016 at 15:41

2

Solved

I'm writing some unit tests against an API that either returns all the books, or only returns the books of the given genre in the query params. This seems to be working when I hit it in my local de...

4

While trying to create my own user model and admin, the test gives the following error. : (admin.E019) The value of 'filter_horizontal[0]' refers to 'groups', which is not an attribute of 'accou...
Inbreathe asked 4/5, 2019 at 1:19

2

Solved

I have a ModelForm that contains some ForeignKey, say to the User object but it could be to any other model. I have a unit test class for this form, but when I am trying to pass it data, I get a Se...
Joann asked 16/12, 2015 at 17:0

1

I have the following (simplified) FBV: def check_existing_contacts(request): if request.is_ajax and request.method == "GET": print('Function called') return mailgun_validate_email(requ...

3

I have two databases that my site uses and I have an app that uses both of them. I need to write a TestCase that loads fixtures for both databases. I use a DB router, which works fine in production...
Fried asked 3/11, 2010 at 4:24

5

Solved

Hi I have an infuriating problem. I have a url pattern like this: # mproject/myapp.urls.py url(r'^project/(?P<project_id>\d+)/$','user_profile.views.EditProject',name='edit_project'), it...
Ilarrold asked 2/11, 2012 at 20:12

4

I am using RequestFactory in a Django test, and I can't find the right way to access the session variable, and I'm getting the following error when I try self.factory._session["zip_id"] or self.fa...
Peccable asked 9/10, 2016 at 18:52

1

I use django.test to do unittest At first i run coverage run ./manage.py test audit.lib.tests.test_prune And works well ---------------------------------------------------------------------- Ran 1...
Tessi asked 23/5, 2021 at 5:1

5

Solved

I use Postgres for production and development, but I'd like to use sqlite to run some tests. I don't see an easy way to configure one engine for tests and another for dev / production. Am I missing...
Triune asked 15/6, 2011 at 4:46

2

Solved

Is there an easy way to get a list of all tests in a Django project without running the tests themselves? I was hoping for something like ./manage.py test --list.
Phonetic asked 3/5, 2013 at 3:59

8

Solved

I have created users for my unit tests in two ways: 1) Create a fixture for "auth.user" that looks roughly like this: { "pk": 1, "model": "auth.user", "fields": { "username": "homer", ...
Transfiguration asked 11/4, 2010 at 23:17

7

Solved

In my django application, I'm trying to write a unit test that performs an action and then checks the messages in the response. As far as I can tell, there is no nice way of doing this. I'm usi...
Epicalyx asked 24/5, 2010 at 14:15

1

Solved

I am using selenium for functional tests with geckodriver and firefox. I see the host is http://localhost:62305 and this is generated in that class with: @classproperty def live_server_url(cls): ...
Gomulka asked 1/9, 2018 at 15:59

© 2022 - 2025 — McMap. All rights reserved.