Run Python/Django Management Command from a UnitTest/WebTest

We have a bunch of commands in our Django site, some that are administrative and some that run on cron jobs that I can't figure out how to test. They pretty much look like this: # Saved in file...

How do I get the user in Django test?

I have some external services. My Django app is built on top of my external service APIs. In order to talk to my external service, I have to pass in an auth cookies, which I can get by reading...

Testing Image upload with Django and Webtest

Does anyone know how I can test the image upload with using WebTest. My current code is: form['avatar'] =('avatar', os.path.join(settings.PROJECT_PATH, 'static', 'img', 'avatar.png')) res =...

Testing Django 1-5 Reset Password Form - how to generate the token for the test?

With the following test, the token is not recognised as valid. In my manual test, it's working so I'm missing something in the way the password is generated I guess. def...

Can I add non existing field to form with WebTest?

I am testing a form using WebTest. However, somes fields are created dynamically using JS, and thus these fields are not in the Form. I have an error when I try to set one of these fields: >>>...

Django-Python Django Login test failed with factory_boy and Authtools

My unit testings are failing when i want to test Login functionality. When I test in my browser is's OK. I'm...

django-webtest: How to test remember-me login/expire-on-browser-close cookies?

How do you test login-remember-me functionality with webtest-django? In other words, how do you use webtest to test things that involve expire-on-browser-exit cookies? I have the below draft, but...

No forms exist in unit test with django-webtest

I want to write a test that will test change the password in the application. I use the django-allauth. For testing, I use django-WebTest. When I run my code, I get the message: FAILED...

Django: Any way to webtest-test password reset, given one-time-only link sent to email?

Is there any way to webtest-test a reset-password request, given the one-time-only-link-sent-by-email part? I'm writing a tutorial on implementing this, and my goal is to create tests for...

testing Django REST Framework

I'm working on my first project which uses Django REST Framework, and I'm having issues testing the API. I'm getting 403 Forbidden errors instead of the expected 200 or 201. However, the API works...

cannot import name to_native_string

I have tried the solutions given in other similar questions but none seem to work. Here are my files: models.py from django.db.models import * from django.contrib.auth.models import User from...

Buildout adding eggs to existing recipe

Edit2: added entire stderr Edit1: deleted my supposed answer. Updated description of problem and added full buildout.cfg text Edit0: fixed links I am trying to port a Pyramid project I have to...

how to force buildout to use already installed package

On a server, for disk optimization, we do not install a C compiler, and here is the problem : I want to install 'spur' python package with buildout 2.3.1, spur is using pycrypto which requires a C...

How to specify name of a Model Form's submit button name via django-webtest

I'm using django-webtest to automate functional tests for a Django application. One of my ModelForms has multiple submit buttons. The template, using django-crispy-forms, looks like this: <form...

How to assign form id to Django ModelForm?

I am using django-webtest to create automated functional tests for my application. As I have multiple forms on a single web page, I'm currently using a hard-coded index to select the form of...

Django WebTest - "Click" the first of two identical links

I'm using Django-WebTest to test a page which contains two links, both with the same class and href, and no id. I'm reading through the WebTest docs and can't seem to find a nice way to click the...

Django WebTest: Check/uncheck checkbox by value

I've got a form with a set of checkboxes (all under the same field name) in my WebTest response, and I'd like to uncheck some of them according to their value. I've tried this: my_form =...

How to check template context using Pyramid + webtest

I'm starting writing tests for my Pyramid views (using webtest), and coming from a Django background I'm having an hard time trying to understand how to test that certain variables have been...

Finding multiple radio buttons of the same name in Django webtest

I'm writing some web tests with the Django webtest where I'm trying to set one radio button in a pair of radio buttons to be checked. Naturally, they both have the same name attribute value. Using...

Writing Testcases for google cloud endpoints API written on top of django

I'm using google cloud endpoints on my django app to provide RESTful services. All API services are working perfectly. Now, it's the time for writing testcases. So I wrote...

App Engine module import issue

I am writing unit tests for a Flask based application running on App Engine. As per the documentation, I have included the following lines import sys sys.path.insert(1,...

ImportError: No module named myapp_o.urls

I have a django-oscar project I am working on. And I have been searching everywhere to solve this problem. Although, I have come across similiar questions here, I still can't solve the problem. I...

Django WebTest - I fill and save a form, data are updated in the new page but not in the database

I have a test in which I create a Profile model with factory_boy and a biography with value 'Starting biography'. Then I get the form from the page and I fill it the bio field with 'Test Updated...

Django ignores test database settings

I have an app deployed on pythonanywhere which runs fine. Problem is that when I want to run test django, my test database settings is completely ignored. Each time I run test I get the following...

Installing MySQL-python causes command 'clang' failed with exit status 1 on Mac OS 10.13.15

I have installed tools via xcode-select --install but still show the following error while doing pip install MySQL-python Building wheels for collected packages: MySQL-python Running setup.py...

upload django site to the web hosting service

Hello im about the finish my first ever django website and I dont know how to upload it to the internet Bcuz I want to buy a web hosting service and to run django server I need to run a command...

Django Views: When is request.data a dict vs a QueryDict?

I have run into some trouble with the issue, that request.data sometimes is a dict (especially when testing) and sometimes a QueryDict instance (when using curl). This is especially a problem...

KeyError: 'collectstatic' When deploying the Django application to pythonanywhere

During the implementation of my Django application on pythonanywhere for the first time I encountered such an error. Previous applications with a very similar structure were able to be implemented...

Using django-webtest with BDD (behave) step definitions

How can I get the benefits of using Webtest inside BDD step definitions (using behave-django), given that I don't have a TestCase to inherit the WebTest class inside the step definition? Is there...

How do you fix a memory leak within Django tests?

Recently I started having some problems with Django (3.1) tests, which I finally tracked down to some kind of memory leak. I normally run my suite (roughly 4000 tests at the moment) with...