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 form validation - assertFalse()

I am quite new to the Django testing software. Right at the moment I am trying to create a test class for validators connected with given form ( process of cleaning the input data): forms.py: class SignupForm(forms.Form): email =…
Artur Drożdżyk
  • 605
  • 1
  • 6
  • 18
0
votes
1 answer

Django 2.0 - Make test worker to run tests in non-app folder

In Django 2.0, I have following project structure, which I can't change, no matter what: grocery_store_website manage.py grocery_store # contains wsgi, settings,etc. app1 app1 non-app-utils __init__.py …
Fusion
  • 5,046
  • 5
  • 42
  • 51
0
votes
0 answers

Does Django re-run all migrations for it's test db?

I am trying to run python manage.py test and it starts off with the usual Creating test database for alias 'default'... but then a pymysql.err.InternalError occurs with the message "Invalid default value for 'expiration_time'". expiration_time is a…
Projjol
  • 1,195
  • 2
  • 12
  • 26
0
votes
0 answers

Django Test with default database and without running any migrations

Is there any way I can use my default local database for testing in Django 1.9. I also don't want to run any migrations, and I want to test it locally. The reason I want to do it this way is that in my migrations, I have a data migration referring…
Shahrukh Mohammad
  • 985
  • 2
  • 17
  • 33
0
votes
1 answer

What do I need to do to get Django Unit Tests working again in PyCharm after renaming a project and its directory?

I have several projects open in one window, some of which are different branches of the same project. I decided to rename the directory and project for one of these branches in PyCharm using the Refactor option on the project. After doing so, the…
hlongmore
  • 1,603
  • 24
  • 28
0
votes
0 answers

Django: How to test invalid object creation

I have a model Student, which, among other fields, contains two fields; mob_student for storing the student's mobile number and mob_parent for storing their parent's number. I have designed the Student model such that a Student object is only…
ryanvb92
  • 311
  • 2
  • 13
0
votes
0 answers

Why my testing view response is none?

I have a post detail view as below. class PostDetailView(AjaxResponseMixin, UpdateView): model = UserPost context_object_name = 'post' template_name = 'feed/post_detail.html' form_class = CommentForm def get_initial(self): initial_data =…
0
votes
2 answers

StaticLiveServerTestCase not logging in

I'm new to python. I'm trying to use StaticLiveServerTestCase with Python to login to the Django admin portal. I'm using the below code. Running the below code launches the admin portal but I'm unable to login with my credentials. Please let me know…
0
votes
1 answer

Run Django tests against an existing database with custom testrunner

I've got an application that is running Django 2 that connects to a Microsoft SQL Server backend. We're in a big environment where things are pretty tightly controlled - a user account has access to the database that houses all the tables for my…
Hanny
  • 2,078
  • 6
  • 24
  • 52
0
votes
1 answer

Django Test Wants Access To Master Database MS SQL Server

I've got an application that is running Django 2 that connects to a Microsoft SQL Server backend. We're in a big environment where things are pretty tightly controlled - a user account has access to the database that houses all the tables for my…
Hanny
  • 2,078
  • 6
  • 24
  • 52
0
votes
1 answer

Django Unit Testing (with DRF): How to test a Passwordresetview?

I'm currently trying to write my unittest for a successfull password reset. TLDR: I can't figure out how to handle the injection of the form data in the post request in the set-password view. For context, let me give you my code first, since a line…
0
votes
1 answer

Disconect models signals in test mode

Is there any way to disconect models signals in test mode Django 1.11 ? Or maybe a way to create an object without ORM to prevent dispaching signal from the post_save method ? setup test code def setUp(self): #some code with patch(post_save): …
Beliaf
  • 577
  • 2
  • 8
  • 25
0
votes
1 answer

Coverage show test get_serializer_class as untested

Use coverage to show what have to be covered by tests drf views. And coverage show that all view is tested ok (cover by unittest + dango client API) But coverage shows that this part need to be covered: def get_serializer_class(self): return…
0
votes
1 answer

How to write a factory for this model in django using factory_boy?

I have a model in my app that contains many_to_many fields on the same model but with a filter. To be more clear this is what I have: class Places(models.Model): user = models.OneToOneField('User') common_kwargs = dict(to='places.Place',…
pietà
  • 760
  • 1
  • 11
  • 37
0
votes
1 answer

test a custom template tag filter in django

To use a template filter like so in a sample_template.html : {% load truck_filters %}
{{model.0}}
# would render
chris Frisina
  • 19,086
  • 22
  • 87
  • 167