Я использую следующее приложение: https://github.com/GoodCloud/django-ajax-uploader
Теперь я написал несколько тестов для проверки успешной загрузки файла.Все работает нормально, пока не дойдет до следующего примера кода.
https://github.com/GoodCloud/django-ajax-uploader/blob/master/ajaxuploader/views.py#L53
success = backend.upload(upload, filename, is_raw)
При запуске я получаю следующую ошибку:
AssertionError: Cannot read more than the available bytes from the HTTP incoming data.
В отладке я нашелвышло, что при остановке теста в этой точке и вызове ...
request.POST
... тест работает нормально, ошибок не появляется и файл загружается.Что за....?Может быть, файл загружается только при остановке теста и в ожидании его загрузки?
Мой след:
AssertionError: Cannot read more than the available bytes from the HTTP incoming data.
Datei "/home/tobi/Projects/academic/src/webapps/django/project/manage.py", Zeile 14, in <module>
execute_manager(settings)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/core/management/__init__.py", Zeile 438, in execute_manager
utility.execute()
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/core/management/__init__.py", Zeile 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/core/management/base.py", Zeile 191, in run_from_argv
self.execute(*args, **options.__dict__)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/core/management/base.py", Zeile 220, in execute
output = self.handle(*args, **options)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/south/management/commands/test.py", Zeile 8, in handle
super(Command, self).handle(*args, **kwargs)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/core/management/commands/test.py", Zeile 37, in handle
failures = test_runner.run_tests(test_labels)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/simple.py", Zeile 360, in run_tests
result = self.run_suite(suite)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/simple.py", Zeile 316, in run_suite
return unittest.TextTestRunner(verbosity=self.verbosity, failfast=self.failfast).run(suite)
Datei "/usr/lib/python2.7/unittest/runner.py", Zeile 151, in run
test(result)
Datei "/usr/lib/python2.7/unittest/suite.py", Zeile 70, in __call__
return self.run(*args, **kwds)
Datei "/usr/lib/python2.7/unittest/suite.py", Zeile 108, in run
test(result)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/testcases.py", Zeile 299, in __call__
super(TransactionTestCase, self).__call__(result)
Datei "/usr/lib/python2.7/unittest/case.py", Zeile 391, in __call__
return self.run(*args, **kwds)
Datei "/usr/lib/python2.7/unittest/case.py", Zeile 327, in run
testMethod()
Datei "/home/tobi/Envs/academic/src/ajaxuploader/ajaxuploader/tests/default_storage_backend.py", Zeile 51, in test_upload_raw_post_local_backend
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/client.py", Zeile 449, in post
response = super(Client, self).post(path, data=data, content_type=content_type, **extra)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/client.py", Zeile 259, in post
return self.request(**r)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/client.py", Zeile 381, in request
response = self.handler(environ)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/client.py", Zeile 84, in __call__
response = self.get_response(request)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/core/handlers/base.py", Zeile 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
Datei "/home/tobi/Envs/academic/src/ajaxuploader/ajaxuploader/views.py", Zeile 15, in __call__
return self._ajax_upload(request)
Datei "/home/tobi/Envs/academic/src/ajaxuploader/ajaxuploader/views.py", Zeile 53, in _ajax_upload
success = backend.upload(upload, filename, is_raw)
Datei "/home/tobi/Envs/academic/src/ajaxuploader/ajaxuploader/backends/base.py", Zeile 27, in upload
chunk = uploaded.read(self.BUFFER_SIZE)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/http/__init__.py", Zeile 301, in read
return self._stream.read(*args, **kwargs)
Datei "/home/tobi/Envs/academic/lib/python2.7/site-packages/django/test/client.py", Zeile 51, in read
assert self.__len >= num_bytes, "Cannot read more than the available bytes from the HTTP incoming data."