Questions tagged [django-webtest]
20 questions
18
votes
2 answers
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 because apparently there is a big difference when calling…

David Schumann
- 13,380
- 9
- 75
- 96
7
votes
3 answers
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 test_actual_reset_password(self):
new_password = "myNewPassword012*"
…

François Constant
- 5,531
- 1
- 33
- 39
6
votes
3 answers
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 = form.submit()
In the response I get the following error…

Ilian Iliev
- 3,217
- 4
- 26
- 51
5
votes
2 answers
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:
>>> resp.form['new_field'] = 'value'
or
>>>…

Gagaro
- 752
- 7
- 17
3
votes
1 answer
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 --parallel=4 which results in a high memory watermark of…

pgcd
- 538
- 6
- 13
3
votes
1 answer
How can I use Basic Authentication with django_webtest to access Django REST framework?
I'm having trouble posting data to some views that use Django REST framework in my tests. I'm using django_webtest to test my user API. I'm running into a problem with the following code:
class UserApiTest(WebTest):
def setUp(self):
…

Jashugan
- 517
- 4
- 13
2
votes
1 answer
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 it's not working. It seems that the server must be…

aliteralmind
- 19,847
- 17
- 77
- 108
2
votes
0 answers
Projects that demonstrate django-webtest?
Can anyone recommend any Django projects that demonstrate how to use the django-webtest package effectively? The documentation for django-webtest (and WebTest as well) is pretty light on real-world examples. Thanks.

Jim
- 13,430
- 26
- 104
- 155
2
votes
1 answer
django-webtest, user authentication and view decorators
I'm using django-webtest (v1.5.6) to test a decorator is limiting access to a view to authenticated users.
My view is simply:
@active_account_required
def homepage(request):
return render(request, 'accounts/account_homepage.html', {
…

edkay
- 181
- 1
- 8
1
vote
2 answers
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 python manage.py runserver and how is the web hosting…

dsal3389
- 658
- 1
- 7
- 26
1
vote
2 answers
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 interest. For instance:
# Forms on this page are:…

Tanuka
- 122
- 1
- 11
1
vote
0 answers
No form exist when I tested changing password in django-allauth
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 (errors=1)
Destroying test database for alias…

mark
- 653
- 1
- 10
- 23
1
vote
1 answer
django-webtest with multiple test client
In django-webtest, every test TestCase subclass comes with self.app, which is an instance of webtest.TestApp, then I could make it login as user A by self.app.get('/',user='A').
However, if I want to test the behavior if for both user A and user B…

Raymond Tau
- 3,429
- 26
- 28
0
votes
1 answer
Django model not working through admin interface
I am working on a auction site using django project. I have a model for placing bid. I have registered the model in admin.py , but when I try to place bid from admin interface it is not updating in the main website page. But through website the bid…

Aravind MS
- 1
- 1
0
votes
1 answer
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 = response.forms['form-i-want']
for i in…

benwad
- 6,414
- 10
- 59
- 93