P
P
Peter Vorontsov2020-05-29 12:40:58
Django
Peter Vorontsov, 2020-05-29 12:40:58

Error with ujson(ValueError: Expected object or value) What's wrong?

@pytest.mark.django_db()
    def test_ajax_update_balance(self, client):
        client, user, useradd = create_test_user_and_force_login(client)
        response = client.post('/ajax-update-balance', {
            'balance': '1001',
        })
        assert response.status_code == 301
        resp = ujson.loads(response.content)
        assert resp['success']

Here is the test code.
If you follow this link "/ajax-update-balance", then there will be: {"balance": 1001}
Error in the console:
ValueError: Expected object or value
What's wrong? All libraries imported and installed, please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-05-29
@bacon

Well, do not follow the link, but before calling loads, see what is in response.content.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question